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