Skip to content

Commit c87010e

Browse files
committed
access houseNumber property correctly instead of using index
- Changed console.log to use address.houseNumber instead of address[0] - Ensures correct display of house number in output
1 parent f02e624 commit c87010e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Sprint-2/debug/address.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
// Predict and explain first...
1+
// The code is trying to log the houseNumber from the address object.
2+
// But it uses address[0], which tries to access the property with key "0".
3+
// Since address is an object with keys like "houseNumber", "street", etc., there is no property 0.
4+
// Therefore, address[0] will be undefined.
5+
// The console will output:
6+
// My house number is undefined
27

38
// This code should log out the houseNumber from the address object
49
// but it isn't working...
@@ -12,4 +17,5 @@ const address = {
1217
postcode: "XYZ 123",
1318
};
1419

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

0 commit comments

Comments
 (0)