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 JavaScript word shows a pop-up box? (a) alert() (b) for (c) let (d) console.log()
- 2.⚡ Which JavaScript word runs code when true? (a) let (b) for (c) if (d) console.log()
-
3.⚡ What does this code print? (Look at the quotes!)
let x = "1";
let y = 7;
console.log(x + y); (a) 8 (b) 17 (c) Error -
4.⚡ What does this code show?
let name = "Kabir";
alert("Hello, " + name + "!"); (a) name (b) Kabir (c) Hello, name! (d) Hello, Kabir! -
5.⚡ What number does this code print?
let marks = 12;
marks = marks + 8;
marks = marks - 20;
console.log(marks); -
6.⚡ What number does this code print?
let runs = 5;
runs = runs + 11;
runs = runs - 10;
console.log(runs); -
7.⚡ What does this code show?
let name = "Kabir";
console.log("Hi, " + name + "!"); (a) Hi, name! (b) name (c) Hi, Kabir! (d) Kabir -
8.⚡ What number does this code print?
let a = 15;
let b = 13;
console.log(a + b); - 9.⚡ Which JavaScript word repeats code? (a) for (b) let (c) if (d) console.log()
- 10.⚡ Which word makes a new variable? (a) make (b) let (c) put (d) give
- 11.⚡ Which JavaScript word writes in the console? (a) if (b) let (c) console.log() (d) alert()
-
12.⚡ What does this code print? (Look at the quotes!)
let x = "3";
let y = 3;
console.log(x + y); (a) 6 (b) 33 (c) Error -
13.⚡ What number does this code print?
let a = 11;
let b = 1;
console.log(a + b); -
14.⚡ What does this code show?
let name = "Arjun";
alert("Hello, " + name + "!"); (a) name (b) Arjun (c) Hello, name! (d) Hello, Arjun! -
15.⚡ What does this code print? (Look at the quotes!)
let x = "8";
let y = 1;
console.log(x + y); (a) 9 (b) Error (c) 81 - 16.⚡ Which tag holds JavaScript in a page? (a) <script> (b) <style> (c) <js> (d) <code>
-
17.⚡ What does this code print? (Look at the quotes!)
let x = "2";
let y = 5;
console.log(x + y); (a) 7 (b) Error (c) 25 - 18.⚡ Which JavaScript word makes a new variable? (a) console.log() (b) for (c) alert() (d) let
-
19.⚡ What does this code show?
let name = "Arjun";
console.log("Hello, " + name + "!"); (a) Hello, Arjun! (b) Hello, name! (c) name (d) Arjun -
20.⚡ What number does this code print?
let a = 59;
let b = 19;
console.log(a - b); -
21.⚡ What number does this code print?
let a = 57;
let b = 23;
console.log(a + b); -
22.⚡ What number does this code print?
let a = 36;
let b = 6;
console.log(a - b); -
23.⚡ What does this code show?
let name = "Kabir";
console.log("Welcome, " + name + "!"); (a) Kabir (b) Welcome, name! (c) name (d) Welcome, Kabir! -
24.⚡ What does this code print? (Look at the quotes!)
let x = "9";
let y = 9;
console.log(x + y); (a) 99 (b) 18 (c) Error -
25.⚡ What does this code print? (Look at the quotes!)
let x = "7";
let y = 4;
console.log(x + y); (a) 74 (b) Error (c) 11 -
26.⚡ What number does this code print?
let coins = 7;
coins = coins + 9;
coins = coins - 1;
console.log(coins); - 27.⚡ A JavaScript file usually ends with which extension? (a) .js (b) .html (c) .jpg (d) .css
-
28.⚡ What does this code show?
let name = "Zoya";
alert("Welcome, " + name + "!"); (a) Welcome, Zoya! (b) name (c) Zoya (d) Welcome, name! -
29.⚡ What number does this code print?
let runs = 26;
runs = runs + 11;
runs = runs - 8;
console.log(runs); -
30.⚡ What does this code print? (Look at the quotes!)
let x = "1";
let y = 3;
console.log(x + y); (a) 4 (b) 13 (c) Error -
31.⚡ What number does this code print?
let runs = 17;
runs = runs + 3;
runs = runs - 7;
console.log(runs); -
32.⚡ What number does this code print?
let coins = 15;
coins = coins + 15;
coins = coins - 9;
console.log(coins); -
33.⚡ What number does this code print?
let a = 46;
let b = 6;
console.log(a + b); - 34.⚡ Where does console.log() show its output? (a) in the console (b) in the address bar (c) on the printer (d) on the title bar
-
35.⚡ What number does this code print?
let coins = 22;
coins = coins + 8;
coins = coins - 25;
console.log(coins); -
36.⚡ What does this code show?
let name = "Zoya";
alert("Hello, " + name + "!"); (a) name (b) Hello, Zoya! (c) Hello, name! (d) Zoya -
37.⚡ What number does this code print?
let marks = 5;
marks = marks + 4;
marks = marks - 3;
console.log(marks); -
38.⚡ What does this code print? (Look at the quotes!)
let x = "2";
let y = 3;
console.log(x + y); (a) Error (b) 5 (c) 23 -
39.⚡ What number does this code print?
let a = 22;
let b = 4;
console.log(a + b); - 40.⚡ What does alert() show? (a) a new tab (b) a table (c) a pop-up box (d) a picture
Answer key
- alert()
- if
- 17
- Hello, Kabir!
- 0
- 6
- Hi, Kabir!
- 28
- for
- let
- console.log()
- 33
- 12
- Hello, Arjun!
- 81
- <script>
- 25
- let
- Hello, Arjun!
- 40
- 80
- 30
- Welcome, Kabir!
- 99
- 74
- 15
- .js
- Welcome, Zoya!
- 29
- 13
- 13
- 21
- 52
- in the console
- 5
- Hello, Zoya!
- 6
- 23
- 26
- a pop-up box
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids