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