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