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