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