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