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