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