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