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