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