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