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