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