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