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