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