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