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