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