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 coins = 25;
coins = coins + 11;
coins = coins - 15;
console.log(coins); - 2.⚡ Where does console.log() show its output? (a) on the title bar (b) in the console (c) on the printer (d) in the address bar
- 3.⚡ Which JavaScript word shows a pop-up box? (a) for (b) let (c) alert() (d) console.log()
-
4.⚡ What number does this code print?
let marks = 19;
marks = marks + 14;
marks = marks - 25;
console.log(marks); -
5.⚡ What does this code print? (Look at the quotes!)
let x = "6";
let y = 5;
console.log(x + y); (a) 65 (b) Error (c) 11 - 6.⚡ Which word makes a new variable? (a) let (b) put (c) make (d) give
- 7.⚡ Which tag holds JavaScript in a page? (a) <code> (b) <style> (c) <js> (d) <script>
-
8.⚡ What does this code print? (Look at the quotes!)
let x = "7";
let y = 2;
console.log(x + y); (a) Error (b) 72 (c) 9 -
9.⚡ What does this code print? (Look at the quotes!)
let x = "1";
let y = 7;
console.log(x + y); (a) Error (b) 17 (c) 8 - 10.⚡ Which JavaScript word repeats code? (a) alert() (b) console.log() (c) if (d) for
-
11.⚡ What number does this code print?
let coins = 18;
coins = coins + 10;
coins = coins - 23;
console.log(coins); -
12.⚡ What does this code print? (Look at the quotes!)
let x = "2";
let y = 6;
console.log(x + y); (a) 8 (b) Error (c) 26 -
13.⚡ What number does this code print?
let apples = 9;
apples = apples + 13;
apples = apples - 16;
console.log(apples); -
14.⚡ What number does this code print?
let a = 3;
let b = 8;
console.log(a * b); -
15.⚡ What number does this code print?
let runs = 7;
runs = runs + 14;
runs = runs - 4;
console.log(runs); - 16.⚡ Which JavaScript word writes in the console? (a) let (b) console.log() (c) alert() (d) if
-
17.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 9;
console.log(x + y); (a) 13 (b) 49 (c) Error - 18.⚡ Which JavaScript word runs code when true? (a) if (b) for (c) console.log() (d) alert()
-
19.⚡ What number does this code print?
let marks = 7;
marks = marks + 2;
marks = marks - 6;
console.log(marks); -
20.⚡ What number does this code print?
let a = 8;
let b = 8;
console.log(a * b); - 21.⚡ A JavaScript file usually ends with which extension? (a) .jpg (b) .html (c) .js (d) .css
-
22.⚡ What number does this code print?
let apples = 26;
apples = apples + 17;
apples = apples - 23;
console.log(apples); -
23.⚡ What does this code show?
let name = "Arjun";
alert("Hi, " + name + "!"); (a) Hi, name! (b) Arjun (c) Hi, Arjun! (d) name -
24.⚡ What does this code print? (Look at the quotes!)
let x = "2";
let y = 9;
console.log(x + y); (a) 29 (b) Error (c) 11 -
25.⚡ What does this code show?
let name = "Arjun";
console.log("Hi, " + name + "!"); (a) name (b) Hi, Arjun! (c) Hi, name! (d) Arjun -
26.⚡ What does this code show?
let name = "Kabir";
alert("Hello, " + name + "!"); (a) Hello, name! (b) Kabir (c) Hello, Kabir! (d) name -
27.⚡ What does this code show?
let name = "Zoya";
alert("Hello, " + name + "!"); (a) name (b) Zoya (c) Hello, name! (d) Hello, Zoya! -
28.⚡ What does this code print? (Look at the quotes!)
let x = "9";
let y = 3;
console.log(x + y); (a) 93 (b) 12 (c) Error - 29.⚡ Which JavaScript word makes a new variable? (a) alert() (b) console.log() (c) for (d) let
-
30.⚡ What number does this code print?
let a = 46;
let b = 30;
console.log(a + b); -
31.⚡ What does this code show?
let name = "Aman";
alert("Hi, " + name + "!"); (a) Hi, name! (b) Hi, Aman! (c) Aman (d) name -
32.⚡ What number does this code print?
let apples = 21;
apples = apples + 8;
apples = apples - 2;
console.log(apples); -
33.⚡ What number does this code print?
let score = 21;
score = score + 11;
score = score - 8;
console.log(score); - 34.⚡ What does alert() show? (a) a table (b) a pop-up box (c) a picture (d) a new tab
-
35.⚡ What number does this code print?
let a = 58;
let b = 21;
console.log(a - b); -
36.⚡ What number does this code print?
let a = 13;
let b = 2;
console.log(a + b); -
37.⚡ What number does this code print?
let score = 28;
score = score + 16;
score = score - 32;
console.log(score); -
38.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 4;
console.log(x + y); (a) 8 (b) 44 (c) Error -
39.⚡ What number does this code print?
let runs = 13;
runs = runs + 19;
runs = runs - 29;
console.log(runs); -
40.⚡ What number does this code print?
let a = 48;
let b = 32;
console.log(a + b);
Answer key
- 21
- in the console
- alert()
- 8
- 65
- let
- <script>
- 72
- 17
- for
- 5
- 26
- 6
- 24
- 17
- console.log()
- 49
- if
- 3
- 64
- .js
- 20
- Hi, Arjun!
- 29
- Hi, Arjun!
- Hello, Kabir!
- Hello, Zoya!
- 93
- let
- 76
- Hi, Aman!
- 27
- 24
- a pop-up box
- 37
- 15
- 12
- 44
- 3
- 80
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids