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