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