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 coins = 27;
coins = coins + 20;
coins = coins - 10;
console.log(coins); -
2.⚡ What does this code show?
let name = "Zoya";
alert("Hi, " + name + "!"); (a) name (b) Hi, Zoya! (c) Hi, name! (d) Zoya -
3.⚡ What does this code print? (Look at the quotes!)
let x = "5";
let y = 4;
console.log(x + y); (a) 9 (b) 54 (c) Error -
4.⚡ What does this code show?
let name = "Meera";
console.log("Hello, " + name + "!"); (a) Meera (b) Hello, Meera! (c) Hello, name! (d) name -
5.⚡ What does this code print? (Look at the quotes!)
let x = "3";
let y = 1;
console.log(x + y); (a) 4 (b) Error (c) 31 -
6.⚡ What number does this code print?
let a = 4;
let b = 8;
console.log(a * b); - 7.⚡ Which JavaScript word writes in the console? (a) console.log() (b) alert() (c) for (d) let
-
8.⚡ What does this code print? (Look at the quotes!)
let x = "8";
let y = 1;
console.log(x + y); (a) 81 (b) 9 (c) Error - 9.⚡ 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
- 10.⚡ What does alert() show? (a) a pop-up box (b) a picture (c) a new tab (d) a table
- 11.⚡ Which JavaScript word makes a new variable? (a) let (b) console.log() (c) if (d) for
- 12.⚡ A JavaScript file usually ends with which extension? (a) .jpg (b) .js (c) .css (d) .html
-
13.⚡ What number does this code print?
let a = 5;
let b = 11;
console.log(a * b); -
14.⚡ What does this code show?
let name = "Arjun";
alert("Well done, " + name + "!"); (a) Arjun (b) name (c) Well done, name! (d) Well done, Arjun! -
15.⚡ What number does this code print?
let a = 48;
let b = 7;
console.log(a + b); -
16.⚡ What number does this code print?
let apples = 20;
apples = apples + 6;
apples = apples - 4;
console.log(apples); -
17.⚡ What does this code show?
let name = "Aman";
alert("Well done, " + name + "!"); (a) Well done, name! (b) Well done, Aman! (c) name (d) Aman -
18.⚡ What does this code print? (Look at the quotes!)
let x = "6";
let y = 2;
console.log(x + y); (a) 8 (b) 62 (c) Error -
19.⚡ What number does this code print?
let score = 25;
score = score + 11;
score = score - 19;
console.log(score); -
20.⚡ What does this code print? (Look at the quotes!)
let x = "8";
let y = 3;
console.log(x + y); (a) 11 (b) Error (c) 83 - 21.⚡ Which JavaScript word shows a pop-up box? (a) for (b) alert() (c) let (d) console.log()
-
22.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 5;
console.log(x + y); (a) Error (b) 45 (c) 9 - 23.⚡ Which JavaScript word runs code when true? (a) console.log() (b) for (c) if (d) alert()
-
24.⚡ What number does this code print?
let coins = 13;
coins = coins + 9;
coins = coins - 18;
console.log(coins); -
25.⚡ What does this code show?
let name = "Kabir";
console.log("Well done, " + name + "!"); (a) name (b) Well done, Kabir! (c) Well done, name! (d) Kabir -
26.⚡ What does this code print? (Look at the quotes!)
let x = "2";
let y = 7;
console.log(x + y); (a) Error (b) 9 (c) 27 -
27.⚡ What number does this code print?
let a = 33;
let b = 8;
console.log(a + b); -
28.⚡ What number does this code print?
let a = 36;
let b = 17;
console.log(a - b); -
29.⚡ What does this code show?
let name = "Aman";
console.log("Well done, " + name + "!"); (a) name (b) Aman (c) Well done, name! (d) Well done, Aman! -
30.⚡ What number does this code print?
let marks = 6;
marks = marks + 5;
marks = marks - 2;
console.log(marks); -
31.⚡ What does this code show?
let name = "Aman";
alert("Hello, " + name + "!"); (a) Hello, name! (b) Hello, Aman! (c) name (d) Aman -
32.⚡ What number does this code print?
let a = 51;
let b = 8;
console.log(a + b); -
33.⚡ What number does this code print?
let marks = 19;
marks = marks + 11;
marks = marks - 5;
console.log(marks); -
34.⚡ What does this code show?
let name = "Kabir";
alert("Hi, " + name + "!"); (a) Kabir (b) Hi, name! (c) Hi, Kabir! (d) name -
35.⚡ What number does this code print?
let books = 27;
books = books + 19;
books = books - 1;
console.log(books); -
36.⚡ What does this code print? (Look at the quotes!)
let x = "9";
let y = 5;
console.log(x + y); (a) Error (b) 95 (c) 14 -
37.⚡ What number does this code print?
let a = 8;
let b = 8;
console.log(a - b); - 38.⚡ Which tag holds JavaScript in a page? (a) <style> (b) <js> (c) <code> (d) <script>
-
39.⚡ What number does this code print?
let a = 12;
let b = 11;
console.log(a * b); -
40.⚡ What number does this code print?
let a = 52;
let b = 28;
console.log(a + b);
Answer key
- 37
- Hi, Zoya!
- 54
- Hello, Meera!
- 31
- 32
- console.log()
- 81
- in the console
- a pop-up box
- let
- .js
- 55
- Well done, Arjun!
- 55
- 22
- Well done, Aman!
- 62
- 17
- 83
- alert()
- 45
- if
- 4
- Well done, Kabir!
- 27
- 41
- 19
- Well done, Aman!
- 9
- Hello, Aman!
- 59
- 25
- Hi, Kabir!
- 45
- 95
- 0
- <script>
- 132
- 80
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids