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 a = 45;
let b = 30;
console.log(a - b); - 2.⚡ Where does console.log() show its output? (a) in the address bar (b) on the title bar (c) on the printer (d) in the console
-
3.⚡ What number does this code print?
let marks = 9;
marks = marks + 10;
marks = marks - 4;
console.log(marks); -
4.⚡ What does this code show?
let name = "Kabir";
console.log("Hello, " + name + "!"); (a) name (b) Kabir (c) Hello, Kabir! (d) Hello, name! -
5.⚡ What does this code show?
let name = "Meera";
console.log("Hello, " + name + "!"); (a) Hello, name! (b) Hello, Meera! (c) name (d) Meera -
6.⚡ What does this code print? (Look at the quotes!)
let x = "7";
let y = 2;
console.log(x + y); (a) 9 (b) Error (c) 72 -
7.⚡ What number does this code print?
let a = 35;
let b = 7;
console.log(a + b); -
8.⚡ What number does this code print?
let a = 2;
let b = 10;
console.log(a * b); - 9.⚡ Which JavaScript word writes in the console? (a) if (b) let (c) alert() (d) console.log()
-
10.⚡ What number does this code print?
let a = 26;
let b = 17;
console.log(a - b); -
11.⚡ What does this code print? (Look at the quotes!)
let x = "5";
let y = 6;
console.log(x + y); (a) Error (b) 56 (c) 11 -
12.⚡ What does this code print? (Look at the quotes!)
let x = "5";
let y = 3;
console.log(x + y); (a) 53 (b) 8 (c) Error - 13.⚡ A JavaScript file usually ends with which extension? (a) .html (b) .css (c) .jpg (d) .js
- 14.⚡ Which JavaScript word repeats code? (a) if (b) let (c) console.log() (d) for
-
15.⚡ What does this code print? (Look at the quotes!)
let x = "2";
let y = 9;
console.log(x + y); (a) 11 (b) 29 (c) Error -
16.⚡ What does this code print? (Look at the quotes!)
let x = "1";
let y = 3;
console.log(x + y); (a) 13 (b) 4 (c) Error -
17.⚡ What does this code show?
let name = "Meera";
console.log("Welcome, " + name + "!"); (a) Welcome, name! (b) Meera (c) name (d) Welcome, Meera! -
18.⚡ 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 -
19.⚡ What number does this code print?
let apples = 20;
apples = apples + 7;
apples = apples - 23;
console.log(apples); -
20.⚡ What number does this code print?
let apples = 24;
apples = apples + 13;
apples = apples - 32;
console.log(apples); - 21.⚡ Which JavaScript word runs code when true? (a) alert() (b) console.log() (c) for (d) if
-
22.⚡ What number does this code print?
let marks = 30;
marks = marks + 20;
marks = marks - 3;
console.log(marks); - 23.⚡ Which JavaScript word shows a pop-up box? (a) let (b) if (c) console.log() (d) alert()
- 24.⚡ Which tag holds JavaScript in a page? (a) <js> (b) <code> (c) <script> (d) <style>
-
25.⚡ What does this code print? (Look at the quotes!)
let x = "8";
let y = 5;
console.log(x + y); (a) 13 (b) Error (c) 85 -
26.⚡ What number does this code print?
let books = 7;
books = books + 3;
books = books - 6;
console.log(books); -
27.⚡ What does this code print? (Look at the quotes!)
let x = "6";
let y = 9;
console.log(x + y); (a) 69 (b) 15 (c) Error -
28.⚡ What number does this code print?
let books = 17;
books = books + 5;
books = books - 10;
console.log(books); -
29.⚡ What does this code print? (Look at the quotes!)
let x = "9";
let y = 9;
console.log(x + y); (a) 99 (b) 18 (c) Error -
30.⚡ What number does this code print?
let a = 6;
let b = 9;
console.log(a * b); - 31.⚡ Which JavaScript word makes a new variable? (a) alert() (b) console.log() (c) let (d) if
-
32.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 6;
console.log(x + y); (a) Error (b) 10 (c) 46 - 33.⚡ What does alert() show? (a) a table (b) a new tab (c) a pop-up box (d) a picture
-
34.⚡ What number does this code print?
let apples = 7;
apples = apples + 10;
apples = apples - 14;
console.log(apples); -
35.⚡ What number does this code print?
let marks = 29;
marks = marks + 20;
marks = marks - 12;
console.log(marks); -
36.⚡ What does this code show?
let name = "Zoya";
alert("Well done, " + name + "!"); (a) name (b) Well done, name! (c) Zoya (d) Well done, Zoya! -
37.⚡ What does this code show?
let name = "Zoya";
console.log("Hi, " + name + "!"); (a) Zoya (b) Hi, name! (c) name (d) Hi, Zoya! -
38.⚡ What number does this code print?
let a = 59;
let b = 10;
console.log(a - b); -
39.⚡ What number does this code print?
let marks = 14;
marks = marks + 18;
marks = marks - 7;
console.log(marks); -
40.⚡ What number does this code print?
let apples = 29;
apples = apples + 17;
apples = apples - 16;
console.log(apples);
Answer key
- 15
- in the console
- 15
- Hello, Kabir!
- Hello, Meera!
- 72
- 42
- 20
- console.log()
- 9
- 56
- 53
- .js
- for
- 29
- 13
- Welcome, Meera!
- 61
- 4
- 5
- if
- 47
- alert()
- <script>
- 85
- 4
- 69
- 12
- 99
- 54
- let
- 46
- a pop-up box
- 3
- 37
- Well done, Zoya!
- Hi, Zoya!
- 49
- 25
- 30
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids