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