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