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