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