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