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