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