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