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