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