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