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