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