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