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