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