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