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