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