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