JavaScript Worksheet: Basics
Code tip (Line by line): let x = 5; makes a variable x holding 5; x = x + 2; changes it to 7. console.log(…) writes in the console; alert(…) shows a pop-up box. Text in quotes + anything = joined text: "5" + 3 → "53".
NameDateTime takenScore ___ / 40
- 1.⚡ Where does console.log() show its output? (a) in the console (b) in the address bar (c) on the title bar (d) on the printer
- 2.⚡ Which tag holds JavaScript in a page? (a) <js> (b) <style> (c) <code> (d) <script>
- 3.⚡ Which word makes a new variable? (a) make (b) put (c) let (d) give
-
4.⚡ What number does this code print?
let score = 17;
score = score + 16;
score = score - 11;
console.log(score); -
5.⚡ What number does this code print?
let apples = 25;
apples = apples + 2;
apples = apples - 3;
console.log(apples); - 6.⚡ Which JavaScript word writes in the console? (a) if (b) alert() (c) console.log() (d) let
- 7.⚡ Which JavaScript word shows a pop-up box? (a) if (b) console.log() (c) alert() (d) for
- 8.⚡ Which JavaScript word makes a new variable? (a) alert() (b) console.log() (c) let (d) for
-
9.⚡ What number does this code print?
let marks = 30;
marks = marks + 11;
marks = marks - 37;
console.log(marks); -
10.⚡ What number does this code print?
let runs = 23;
runs = runs + 3;
runs = runs - 22;
console.log(runs); -
11.⚡ What number does this code print?
let a = 17;
let b = 14;
console.log(a + b); - 12.⚡ What does alert() show? (a) a new tab (b) a picture (c) a table (d) a pop-up box
- 13.⚡ What does JavaScript add to a web page? (a) only colours (b) the page title (c) the domain name (d) actions and changes
-
14.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 3;
console.log(x + y); (a) 7 (b) Error (c) 43 -
15.⚡ What does this code print? (Look at the quotes!)
let x = "7";
let y = 2;
console.log(x + y); (a) 9 (b) 72 (c) Error - 16.⚡ Which JavaScript word repeats code? (a) alert() (b) console.log() (c) for (d) let
-
17.⚡ What number does this code print?
let a = 38;
let b = 27;
console.log(a + b); -
18.⚡ What does this code print? (Look at the quotes!)
let x = "5";
let y = 7;
console.log(x + y); (a) 12 (b) Error (c) 57 - 19.⚡ Which JavaScript word runs code when true? (a) for (b) alert() (c) if (d) console.log()
-
20.⚡ What does this code print? (Look at the quotes!)
let x = "1";
let y = 2;
console.log(x + y); (a) 3 (b) Error (c) 12 -
21.⚡ What does this code print? (Look at the quotes!)
let x = "5";
let y = 5;
console.log(x + y); (a) Error (b) 10 (c) 55 -
22.⚡ What number does this code print?
let a = 60;
let b = 8;
console.log(a - b); -
23.⚡ What number does this code print?
let a = 11;
let b = 6;
console.log(a * b); -
24.⚡ What number does this code print?
let a = 53;
let b = 22;
console.log(a + b); -
25.⚡ What number does this code print?
let books = 29;
books = books + 17;
books = books - 23;
console.log(books); -
26.⚡ What does this code show?
let name = "Meera";
alert("Well done, " + name + "!"); (a) Well done, name! (b) Meera (c) Well done, Meera! (d) name -
27.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 1;
console.log(x + y); (a) 5 (b) 41 (c) Error - 28.⚡ A JavaScript file usually ends with which extension? (a) .html (b) .js (c) .css (d) .jpg
-
29.⚡ What number does this code print?
let a = 3;
let b = 10;
console.log(a * b); -
30.⚡ What does this code print? (Look at the quotes!)
let x = "2";
let y = 2;
console.log(x + y); (a) Error (b) 22 (c) 4 -
31.⚡ What does this code show?
let name = "Meera";
alert("Hi, " + name + "!"); (a) name (b) Hi, Meera! (c) Hi, name! (d) Meera -
32.⚡ What number does this code print?
let a = 10;
let b = 13;
console.log(a + b); -
33.⚡ What does this code show?
let name = "Arjun";
console.log("Well done, " + name + "!"); (a) Well done, name! (b) name (c) Arjun (d) Well done, Arjun! -
34.⚡ What does this code show?
let name = "Riya";
console.log("Hello, " + name + "!"); (a) Hello, Riya! (b) Riya (c) name (d) Hello, name! -
35.⚡ What number does this code print?
let a = 4;
let b = 4;
console.log(a * b); -
36.⚡ What number does this code print?
let a = 5;
let b = 9;
console.log(a * b); -
37.⚡ What does this code show?
let name = "Aman";
alert("Well done, " + name + "!"); (a) name (b) Aman (c) Well done, name! (d) Well done, Aman! -
38.⚡ What does this code show?
let name = "Riya";
alert("Welcome, " + name + "!"); (a) name (b) Welcome, name! (c) Riya (d) Welcome, Riya! -
39.⚡ What does this code print? (Look at the quotes!)
let x = "8";
let y = 3;
console.log(x + y); (a) Error (b) 11 (c) 83 -
40.⚡ What number does this code print?
let runs = 24;
runs = runs + 10;
runs = runs - 31;
console.log(runs);
Answer key
- in the console
- <script>
- let
- 22
- 24
- console.log()
- alert()
- let
- 4
- 4
- 31
- a pop-up box
- actions and changes
- 43
- 72
- for
- 65
- 57
- if
- 12
- 55
- 52
- 66
- 75
- 23
- Well done, Meera!
- 41
- .js
- 30
- 22
- Hi, Meera!
- 23
- Well done, Arjun!
- Hello, Riya!
- 16
- 45
- Well done, Aman!
- Welcome, Riya!
- 83
- 3
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids