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