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