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