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