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