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