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 = 20;
let b = 28;
console.log(a + b); - 2.⚡ A JavaScript file usually ends with which extension? (a) .css (b) .html (c) .jpg (d) .js
-
3.⚡ What number does this code print?
let runs = 21;
runs = runs + 15;
runs = runs - 11;
console.log(runs); -
4.⚡ What number does this code print?
let a = 56;
let b = 38;
console.log(a - b); -
5.⚡ What does this code print? (Look at the quotes!)
let x = "8";
let y = 6;
console.log(x + y); (a) 86 (b) 14 (c) Error -
6.⚡ What number does this code print?
let marks = 6;
marks = marks + 18;
marks = marks - 15;
console.log(marks); -
7.⚡ What number does this code print?
let a = 9;
let b = 3;
console.log(a * b); -
8.⚡ What number does this code print?
let a = 17;
let b = 19;
console.log(a + b); -
9.⚡ What number does this code print?
let a = 55;
let b = 25;
console.log(a + b); -
10.⚡ What number does this code print?
let a = 11;
let b = 22;
console.log(a + b); - 11.⚡ Which tag holds JavaScript in a page? (a) <style> (b) <js> (c) <code> (d) <script>
-
12.⚡ What number does this code print?
let marks = 12;
marks = marks + 20;
marks = marks - 25;
console.log(marks); -
13.⚡ What does this code show?
let name = "Kabir";
console.log("Hello, " + name + "!"); (a) Kabir (b) name (c) Hello, Kabir! (d) Hello, name! -
14.⚡ What number does this code print?
let runs = 27;
runs = runs + 12;
runs = runs - 28;
console.log(runs); -
15.⚡ What number does this code print?
let a = 23;
let b = 38;
console.log(a + b); - 16.⚡ Which JavaScript word writes in the console? (a) let (b) for (c) console.log() (d) if
-
17.⚡ What number does this code print?
let apples = 8;
apples = apples + 6;
apples = apples - 3;
console.log(apples); - 18.⚡ Which JavaScript word runs code when true? (a) if (b) for (c) console.log() (d) alert()
-
19.⚡ What does this code print? (Look at the quotes!)
let x = "6";
let y = 9;
console.log(x + y); (a) 15 (b) Error (c) 69 -
20.⚡ What number does this code print?
let coins = 9;
coins = coins + 5;
coins = coins - 12;
console.log(coins); -
21.⚡ What number does this code print?
let books = 30;
books = books + 2;
books = books - 28;
console.log(books); -
22.⚡ What number does this code print?
let a = 11;
let b = 1;
console.log(a + b); - 23.⚡ Which JavaScript word repeats code? (a) alert() (b) for (c) if (d) console.log()
- 24.⚡ 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
-
25.⚡ What number does this code print?
let a = 59;
let b = 29;
console.log(a + b); -
26.⚡ What number does this code print?
let marks = 10;
marks = marks + 20;
marks = marks - 3;
console.log(marks); - 27.⚡ Which JavaScript word makes a new variable? (a) for (b) console.log() (c) alert() (d) let
- 28.⚡ Which JavaScript word shows a pop-up box? (a) let (b) if (c) for (d) alert()
- 29.⚡ Which word makes a new variable? (a) make (b) give (c) put (d) let
-
30.⚡ What number does this code print?
let a = 44;
let b = 32;
console.log(a + b); -
31.⚡ What does this code print? (Look at the quotes!)
let x = "4";
let y = 1;
console.log(x + y); (a) Error (b) 5 (c) 41 -
32.⚡ What number does this code print?
let a = 35;
let b = 17;
console.log(a - b); -
33.⚡ What number does this code print?
let books = 22;
books = books + 7;
books = books - 5;
console.log(books); -
34.⚡ What does this code print? (Look at the quotes!)
let x = "5";
let y = 8;
console.log(x + y); (a) 13 (b) 58 (c) Error -
35.⚡ What number does this code print?
let books = 29;
books = books + 2;
books = books - 2;
console.log(books); -
36.⚡ What does this code print? (Look at the quotes!)
let x = "5";
let y = 3;
console.log(x + y); (a) 53 (b) Error (c) 8 -
37.⚡ What number does this code print?
let apples = 15;
apples = apples + 12;
apples = apples - 23;
console.log(apples); -
38.⚡ What number does this code print?
let a = 5;
let b = 39;
console.log(a + b); -
39.⚡ What does this code show?
let name = "Meera";
console.log("Hello, " + name + "!"); (a) Meera (b) Hello, name! (c) name (d) Hello, Meera! -
40.⚡ What number does this code print?
let a = 31;
let b = 23;
console.log(a - b);
Answer key
- 48
- .js
- 25
- 18
- 86
- 9
- 27
- 36
- 80
- 33
- <script>
- 7
- Hello, Kabir!
- 11
- 61
- console.log()
- 11
- if
- 69
- 2
- 4
- 12
- for
- in the console
- 88
- 27
- let
- alert()
- let
- 76
- 41
- 18
- 24
- 58
- 29
- 53
- 4
- 44
- Hello, Meera!
- 8
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids