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