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