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