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