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