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