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