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.⚡ 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
- 2.⚡ Which JavaScript word shows a pop-up box? (a) let (b) if (c) alert() (d) console.log()
-
3.⚡ What number does this code print?
let a = 58;
let b = 7;
console.log(a + b); -
4.⚡ What number does this code print?
let a = 6;
let b = 4;
console.log(a * b); -
5.⚡ What does this code print? (Look at the quotes!)
let x = "5";
let y = 8;
console.log(x + y); (a) 58 (b) 13 (c) Error -
6.⚡ What does this code print? (Look at the quotes!)
let x = "7";
let y = 8;
console.log(x + y); (a) 15 (b) Error (c) 78 -
7.⚡ What number does this code print?
let score = 12;
score = score + 12;
score = score - 3;
console.log(score); - 8.⚡ Which word makes a new variable? (a) make (b) put (c) let (d) give
- 9.⚡ What does JavaScript add to a web page? (a) only colours (b) the domain name (c) the page title (d) actions and changes
-
10.⚡ What does this code print? (Look at the quotes!)
let x = "7";
let y = 3;
console.log(x + y); (a) 10 (b) 73 (c) Error -
11.⚡ What does this code print? (Look at the quotes!)
let x = "2";
let y = 1;
console.log(x + y); (a) Error (b) 21 (c) 3 - 12.⚡ Which JavaScript word repeats code? (a) alert() (b) for (c) console.log() (d) if
-
13.⚡ What number does this code print?
let a = 43;
let b = 31;
console.log(a + b); -
14.⚡ What does this code print? (Look at the quotes!)
let x = "3";
let y = 3;
console.log(x + y); (a) 6 (b) 33 (c) Error -
15.⚡ What number does this code print?
let a = 13;
let b = 9;
console.log(a + b); -
16.⚡ What number does this code print?
let a = 59;
let b = 8;
console.log(a + b); -
17.⚡ What does this code print? (Look at the quotes!)
let x = "8";
let y = 8;
console.log(x + y); (a) Error (b) 16 (c) 88 -
18.⚡ What number does this code print?
let a = 11;
let b = 38;
console.log(a + b); -
19.⚡ What number does this code print?
let a = 6;
let b = 11;
console.log(a * b); -
20.⚡ What does this code show?
let name = "Aman";
console.log("Well done, " + name + "!"); (a) Aman (b) Well done, Aman! (c) name (d) Well done, name! - 21.⚡ What does alert() show? (a) a picture (b) a table (c) a pop-up box (d) a new tab
-
22.⚡ What number does this code print?
let coins = 22;
coins = coins + 3;
coins = coins - 18;
console.log(coins); -
23.⚡ What number does this code print?
let a = 2;
let b = 12;
console.log(a * b); - 24.⚡ Which JavaScript word makes a new variable? (a) console.log() (b) alert() (c) let (d) for
-
25.⚡ What number does this code print?
let marks = 9;
marks = marks + 14;
marks = marks - 23;
console.log(marks); -
26.⚡ What number does this code print?
let score = 8;
score = score + 18;
score = score - 25;
console.log(score); -
27.⚡ What number does this code print?
let a = 10;
let b = 2;
console.log(a * b); - 28.⚡ Which JavaScript word runs code when true? (a) for (b) let (c) alert() (d) if
-
29.⚡ What does this code print? (Look at the quotes!)
let x = "2";
let y = 9;
console.log(x + y); (a) Error (b) 11 (c) 29 -
30.⚡ What number does this code print?
let books = 27;
books = books + 16;
books = books - 14;
console.log(books); -
31.⚡ What number does this code print?
let a = 12;
let b = 11;
console.log(a - b); - 32.⚡ Which JavaScript word writes in the console? (a) alert() (b) if (c) console.log() (d) for
- 33.⚡ Which tag holds JavaScript in a page? (a) <script> (b) <style> (c) <code> (d) <js>
-
34.⚡ What does this code show?
let name = "Zoya";
alert("Welcome, " + name + "!"); (a) Welcome, name! (b) Zoya (c) Welcome, Zoya! (d) name -
35.⚡ What number does this code print?
let a = 9;
let b = 2;
console.log(a * b); -
36.⚡ What number does this code print?
let books = 24;
books = books + 15;
books = books - 13;
console.log(books); -
37.⚡ What does this code show?
let name = "Arjun";
alert("Hi, " + name + "!"); (a) Arjun (b) name (c) Hi, name! (d) Hi, Arjun! -
38.⚡ What does this code show?
let name = "Zoya";
console.log("Hello, " + name + "!"); (a) Zoya (b) Hello, Zoya! (c) Hello, name! (d) name -
39.⚡ What number does this code print?
let apples = 10;
apples = apples + 10;
apples = apples - 12;
console.log(apples); -
40.⚡ What number does this code print?
let a = 8;
let b = 6;
console.log(a * b);
Answer key
- in the console
- alert()
- 65
- 24
- 58
- 78
- 21
- let
- actions and changes
- 73
- 21
- for
- 74
- 33
- 22
- 67
- 88
- 49
- 66
- Well done, Aman!
- a pop-up box
- 7
- 24
- let
- 0
- 1
- 20
- if
- 29
- 29
- 1
- console.log()
- <script>
- Welcome, Zoya!
- 18
- 26
- Hi, Arjun!
- Hello, Zoya!
- 8
- 48
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids