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