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