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