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