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