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