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