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