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