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