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