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