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