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