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