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