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.⚡ Where does console.log() show its output? (a) in the address bar (b) on the title bar (c) in the console (d) on the printer
-
3.⚡ What does this code show?
let name = "Arjun";
alert("Welcome, " + name + "!"); (a) Arjun (b) Welcome, name! (c) Welcome, Arjun! (d) name -
4.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 5;
console.log(x + y); (a) Error (b) 9 (c) 45 -
5.⚡ What number does this code print?
let a = 10;
let b = 4;
console.log(a * b); -
6.⚡ What does this code show?
let name = "Arjun";
alert("Hi, " + name + "!"); (a) Arjun (b) Hi, name! (c) Hi, Arjun! (d) name -
7.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 8;
console.log(x + y); (a) Error (b) 48 (c) 12 -
8.⚡ What number does this code print?
let marks = 29;
marks = marks + 12;
marks = marks - 12;
console.log(marks); -
9.⚡ What does this code show?
let name = "Riya";
alert("Hi, " + name + "!"); (a) Hi, Riya! (b) Riya (c) name (d) Hi, name! -
10.⚡ What number does this code print?
let a = 7;
let b = 8;
console.log(a * b); - 11.⚡ What does alert() show? (a) a new tab (b) a picture (c) a pop-up box (d) a table
-
12.⚡ 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 -
13.⚡ 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 -
14.⚡ What does this code show?
let name = "Zoya";
console.log("Welcome, " + name + "!"); (a) Zoya (b) Welcome, name! (c) name (d) Welcome, Zoya! -
15.⚡ What number does this code print?
let runs = 22;
runs = runs + 17;
runs = runs - 8;
console.log(runs); -
16.⚡ What number does this code print?
let a = 28;
let b = 3;
console.log(a - b); -
17.⚡ What number does this code print?
let a = 12;
let b = 10;
console.log(a * b); - 18.⚡ Which JavaScript word runs code when true? (a) for (b) alert() (c) if (d) let
-
19.⚡ What number does this code print?
let runs = 28;
runs = runs + 4;
runs = runs - 19;
console.log(runs); -
20.⚡ What number does this code print?
let a = 47;
let b = 39;
console.log(a + b); -
21.⚡ What number does this code print?
let a = 28;
let b = 11;
console.log(a - b); -
22.⚡ What does this code print? (Look at the quotes!)
let x = "1";
let y = 9;
console.log(x + y); (a) 10 (b) 19 (c) Error -
23.⚡ What does this code show?
let name = "Meera";
console.log("Well done, " + name + "!"); (a) Well done, Meera! (b) Well done, name! (c) Meera (d) name - 24.⚡ Which JavaScript word repeats code? (a) let (b) if (c) for (d) console.log()
- 25.⚡ Which JavaScript word shows a pop-up box? (a) if (b) console.log() (c) alert() (d) let
-
26.⚡ What does this code show?
let name = "Kabir";
alert("Hi, " + name + "!"); (a) name (b) Kabir (c) Hi, name! (d) Hi, Kabir! - 27.⚡ Which JavaScript word writes in the console? (a) alert() (b) let (c) console.log() (d) if
-
28.⚡ What number does this code print?
let a = 45;
let b = 9;
console.log(a - b); -
29.⚡ What number does this code print?
let books = 24;
books = books + 4;
books = books - 7;
console.log(books); -
30.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 9;
console.log(x + y); (a) 49 (b) 13 (c) Error -
31.⚡ What number does this code print?
let a = 24;
let b = 6;
console.log(a - b); - 32.⚡ Which tag holds JavaScript in a page? (a) <js> (b) <script> (c) <code> (d) <style>
-
33.⚡ What does this code print? (Look at the quotes!)
let x = "1";
let y = 3;
console.log(x + y); (a) 4 (b) Error (c) 13 -
34.⚡ What does this code show?
let name = "Arjun";
console.log("Well done, " + name + "!"); (a) Arjun (b) Well done, name! (c) name (d) Well done, Arjun! -
35.⚡ What number does this code print?
let a = 2;
let b = 12;
console.log(a * b); -
36.⚡ What number does this code print?
let books = 6;
books = books + 9;
books = books - 4;
console.log(books); -
37.⚡ What does this code show?
let name = "Kabir";
console.log("Well done, " + name + "!"); (a) Well done, name! (b) Kabir (c) Well done, Kabir! (d) name - 38.⚡ Which JavaScript word makes a new variable? (a) let (b) console.log() (c) for (d) alert()
-
39.⚡ What number does this code print?
let a = 32;
let b = 18;
console.log(a - b); -
40.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 4;
console.log(x + y); (a) 8 (b) Error (c) 44
Answer key
- .js
- in the console
- Welcome, Arjun!
- 45
- 40
- Hi, Arjun!
- 48
- 29
- Hi, Riya!
- 56
- a pop-up box
- 69
- 55
- Welcome, Zoya!
- 31
- 25
- 120
- if
- 13
- 86
- 17
- 19
- Well done, Meera!
- for
- alert()
- Hi, Kabir!
- console.log()
- 36
- 21
- 49
- 18
- <script>
- 13
- Well done, Arjun!
- 24
- 11
- Well done, Kabir!
- let
- 14
- 44
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids