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