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