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