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