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.⚡ A JavaScript file usually ends with which extension? (a) .js (b) .css (c) .jpg (d) .html
-
2.⚡ What does this code show?
let name = "Aman";
console.log("Well done, " + name + "!"); (a) Well done, Aman! (b) Well done, name! (c) name (d) Aman -
3.⚡ What does this code print? (Look at the quotes!)
let x = "7";
let y = 8;
console.log(x + y); (a) Error (b) 15 (c) 78 -
4.⚡ What number does this code print?
let runs = 10;
runs = runs + 18;
runs = runs - 14;
console.log(runs); - 5.⚡ Which word makes a new variable? (a) make (b) let (c) give (d) put
- 6.⚡ Which JavaScript word repeats code? (a) let (b) if (c) alert() (d) for
- 7.⚡ What does JavaScript add to a web page? (a) actions and changes (b) only colours (c) the domain name (d) the page title
-
8.⚡ What number does this code print?
let score = 20;
score = score + 12;
score = score - 18;
console.log(score); -
9.⚡ What does this code show?
let name = "Riya";
console.log("Well done, " + name + "!"); (a) Riya (b) Well done, Riya! (c) name (d) Well done, name! -
10.⚡ What number does this code print?
let a = 49;
let b = 2;
console.log(a + b); -
11.⚡ What does this code show?
let name = "Meera";
alert("Hi, " + name + "!"); (a) Hi, name! (b) Meera (c) Hi, Meera! (d) name -
12.⚡ What number does this code print?
let a = 2;
let b = 6;
console.log(a * b); -
13.⚡ What number does this code print?
let a = 9;
let b = 5;
console.log(a * b); -
14.⚡ What number does this code print?
let a = 6;
let b = 27;
console.log(a + b); -
15.⚡ What number does this code print?
let a = 56;
let b = 4;
console.log(a + b); -
16.⚡ What number does this code print?
let a = 29;
let b = 2;
console.log(a - b); - 17.⚡ Where does console.log() show its output? (a) on the title bar (b) in the address bar (c) on the printer (d) in the console
- 18.⚡ What does alert() show? (a) a picture (b) a new tab (c) a table (d) a pop-up box
- 19.⚡ Which JavaScript word shows a pop-up box? (a) console.log() (b) let (c) alert() (d) if
-
20.⚡ What number does this code print?
let a = 13;
let b = 22;
console.log(a + b); -
21.⚡ What number does this code print?
let a = 52;
let b = 39;
console.log(a + b); -
22.⚡ What number does this code print?
let a = 20;
let b = 23;
console.log(a + b); -
23.⚡ 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 -
24.⚡ What does this code print? (Look at the quotes!)
let x = "1";
let y = 7;
console.log(x + y); (a) 8 (b) 17 (c) Error -
25.⚡ What does this code show?
let name = "Kabir";
console.log("Hi, " + name + "!"); (a) Hi, Kabir! (b) Kabir (c) Hi, name! (d) name -
26.⚡ What does this code print? (Look at the quotes!)
let x = "9";
let y = 8;
console.log(x + y); (a) 17 (b) 98 (c) Error -
27.⚡ What number does this code print?
let a = 14;
let b = 17;
console.log(a + b); -
28.⚡ What number does this code print?
let score = 29;
score = score + 16;
score = score - 8;
console.log(score); -
29.⚡ What number does this code print?
let marks = 22;
marks = marks + 17;
marks = marks - 18;
console.log(marks); -
30.⚡ What number does this code print?
let a = 7;
let b = 8;
console.log(a + b); - 31.⚡ Which JavaScript word writes in the console? (a) alert() (b) if (c) for (d) console.log()
-
32.⚡ What does this code print? (Look at the quotes!)
let x = "8";
let y = 6;
console.log(x + y); (a) Error (b) 14 (c) 86 -
33.⚡ What number does this code print?
let a = 8;
let b = 3;
console.log(a * b); -
34.⚡ What does this code print? (Look at the quotes!)
let x = "1";
let y = 2;
console.log(x + y); (a) Error (b) 12 (c) 3 -
35.⚡ What number does this code print?
let a = 10;
let b = 12;
console.log(a * b); -
36.⚡ What number does this code print?
let a = 7;
let b = 6;
console.log(a * b); -
37.⚡ What does this code print? (Look at the quotes!)
let x = "2";
let y = 2;
console.log(x + y); (a) Error (b) 4 (c) 22 -
38.⚡ What number does this code print?
let a = 25;
let b = 5;
console.log(a + b); -
39.⚡ What does this code print? (Look at the quotes!)
let x = "2";
let y = 5;
console.log(x + y); (a) 25 (b) 7 (c) Error - 40.⚡ Which JavaScript word runs code when true? (a) alert() (b) let (c) if (d) console.log()
Answer key
- .js
- Well done, Aman!
- 78
- 14
- let
- for
- actions and changes
- 14
- Well done, Riya!
- 51
- Hi, Meera!
- 12
- 45
- 33
- 60
- 27
- in the console
- a pop-up box
- alert()
- 35
- 91
- 43
- 83
- 17
- Hi, Kabir!
- 98
- 31
- 37
- 21
- 15
- console.log()
- 86
- 24
- 12
- 120
- 42
- 22
- 30
- 25
- if
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids