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