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