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