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