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