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