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