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