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