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