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