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