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