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