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