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