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