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