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