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