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