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