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