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