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