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