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