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