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