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