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