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