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