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