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