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