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