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