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