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