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