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