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