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