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