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