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