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