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