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