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