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