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