Skip to content

Commit b057112

Browse files
committed
Fix address lookup by using correct object property
1 parent 64a2b80 commit b057112

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎Sprint-2/debug/address.js‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44
// but it isn't working...
55
// Fix anything that isn't working
66

7+
/*const address = {
8+
houseNumber: 42,
9+
street: "Imaginary Road",
10+
city: "Manchester",
11+
country: "England",
12+
postcode: "XYZ 123",
13+
};
14+
15+
console.log(`My house number is ${address[0]}`); */
16+
17+
// The line "address[0]" is wrong. Because address is an object not an array, so "address[0]" is undefined. The output will be "My house number is undefined".
18+
19+
// Corrected code
720
const address = {
821
houseNumber: 42,
922
street: "Imaginary Road",
@@ -12,4 +25,4 @@ const address = {
1225
postcode: "XYZ 123",
1326
};
1427

15-
console.log(`My house number is ${address[0]}`);
28+
console.log(`My house number is ${address.houseNumber}`);

0 commit comments

Comments
 (0)