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