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