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