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 tag holds JavaScript in a page? (a) <style> (b) <code> (c) <script> (d) <js>
- 2.⚡ Which word makes a new variable? (a) let (b) put (c) make (d) give
-
3.⚡ What number does this code print?
let score = 11;
score = score + 13;
score = score - 10;
console.log(score); - 4.⚡ Which JavaScript word writes in the console? (a) alert() (b) console.log() (c) let (d) for
- 5.⚡ Which JavaScript word shows a pop-up box? (a) if (b) console.log() (c) let (d) alert()
-
6.⚡ What number does this code print?
let a = 9;
let b = 9;
console.log(a * b); -
7.⚡ What does this code show?
let name = "Riya";
alert("Welcome, " + name + "!"); (a) Welcome, Riya! (b) Riya (c) Welcome, name! (d) name -
8.⚡ What number does this code print?
let coins = 11;
coins = coins + 8;
coins = coins - 15;
console.log(coins); -
9.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 4;
console.log(x + y); (a) 8 (b) 44 (c) Error -
10.⚡ What number does this code print?
let a = 49;
let b = 1;
console.log(a - b); -
11.⚡ What number does this code print?
let runs = 27;
runs = runs + 9;
runs = runs - 5;
console.log(runs); -
12.⚡ What number does this code print?
let marks = 28;
marks = marks + 14;
marks = marks - 2;
console.log(marks); -
13.⚡ What number does this code print?
let a = 50;
let b = 37;
console.log(a - b); - 14.⚡ Which JavaScript word makes a new variable? (a) if (b) console.log() (c) for (d) let
- 15.⚡ Which JavaScript word repeats code? (a) for (b) if (c) let (d) console.log()
-
16.⚡ What number does this code print?
let coins = 21;
coins = coins + 5;
coins = coins - 3;
console.log(coins); -
17.⚡ 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 -
18.⚡ What does this code print? (Look at the quotes!)
let x = "5";
let y = 4;
console.log(x + y); (a) 9 (b) 54 (c) Error -
19.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 5;
console.log(x + y); (a) 45 (b) 9 (c) Error -
20.⚡ What number does this code print?
let coins = 12;
coins = coins + 11;
coins = coins - 1;
console.log(coins); -
21.⚡ What number does this code print?
let a = 10;
let b = 9;
console.log(a * b); -
22.⚡ 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 -
23.⚡ What number does this code print?
let marks = 11;
marks = marks + 14;
marks = marks - 2;
console.log(marks); -
24.⚡ What does this code print? (Look at the quotes!)
let x = "3";
let y = 6;
console.log(x + y); (a) 9 (b) Error (c) 36 -
25.⚡ What number does this code print?
let runs = 29;
runs = runs + 3;
runs = runs - 18;
console.log(runs); -
26.⚡ What does this code print? (Look at the quotes!)
let x = "2";
let y = 1;
console.log(x + y); (a) 21 (b) Error (c) 3 -
27.⚡ What number does this code print?
let a = 2;
let b = 10;
console.log(a * b); -
28.⚡ What does this code show?
let name = "Aman";
alert("Well done, " + name + "!"); (a) Well done, name! (b) name (c) Well done, Aman! (d) Aman -
29.⚡ What number does this code print?
let a = 10;
let b = 5;
console.log(a * b); - 30.⚡ Where does console.log() show its output? (a) on the title bar (b) on the printer (c) in the address bar (d) in the console
-
31.⚡ What does this code print? (Look at the quotes!)
let x = "3";
let y = 9;
console.log(x + y); (a) Error (b) 39 (c) 12 - 32.⚡ What does alert() show? (a) a new tab (b) a table (c) a pop-up box (d) a picture
-
33.⚡ What does this code print? (Look at the quotes!)
let x = "9";
let y = 7;
console.log(x + y); (a) 16 (b) Error (c) 97 -
34.⚡ What number does this code print?
let a = 7;
let b = 4;
console.log(a * b); -
35.⚡ What does this code print? (Look at the quotes!)
let x = "1";
let y = 7;
console.log(x + y); (a) 8 (b) Error (c) 17 -
36.⚡ What number does this code print?
let a = 40;
let b = 26;
console.log(a - b); -
37.⚡ What number does this code print?
let marks = 8;
marks = marks + 3;
marks = marks - 7;
console.log(marks); -
38.⚡ What number does this code print?
let a = 10;
let b = 7;
console.log(a + b); -
39.⚡ What does this code show?
let name = "Riya";
console.log("Well done, " + name + "!"); (a) name (b) Well done, name! (c) Riya (d) Well done, Riya! -
40.⚡ What number does this code print?
let a = 36;
let b = 29;
console.log(a - b);
Answer key
- <script>
- let
- 14
- console.log()
- alert()
- 81
- Welcome, Riya!
- 4
- 44
- 48
- 31
- 40
- 13
- let
- for
- 23
- 99
- 54
- 45
- 22
- 90
- 74
- 23
- 36
- 14
- 21
- 20
- Well done, Aman!
- 50
- in the console
- 39
- a pop-up box
- 97
- 28
- 17
- 14
- 4
- 17
- Well done, Riya!
- 7
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids