Skip to content

Commit 9819f2c

Browse files
committed
Revert "predicted the result of each file before fixing them"
This reverts commit f21c96e.
1 parent 250453e commit 9819f2c

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

Sprint-2/debug/address.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// Predict and explain first...
2-
//the original code is using the wrong notation to access our object this will return undefined as we do not have a 0 property.
32

43
// This code should log out the houseNumber from the address object
54
// but it isn't working...
65
// Fix anything that isn't working
7-
//fixed it by puting "houseNumber" in the square brackets.
86

97
const address = {
108
houseNumber: 42,
@@ -14,4 +12,4 @@ const address = {
1412
postcode: "XYZ 123",
1513
};
1614

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

Sprint-2/debug/author.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Predict and explain first...
2-
//the method for of is an array method and it would be looking for an indexed list of items rather than a key value pair so an error will be thrown since we are using an object.
32

43
// This program attempts to log out all the property values in the object.
54
// But it isn't working. Explain why first and then fix the problem
6-
//i can fix this by changing for ... of to for ... in.
75

86
const author = {
97
firstName: "Zadie",
@@ -13,6 +11,6 @@ const author = {
1311
alive: true,
1412
};
1513

16-
for (const value in author) {
14+
for (const value of author) {
1715
console.log(value);
1816
}

Sprint-2/debug/recipe.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
// Predict and explain first...
2-
//it will display the title and number of people it serves on one line then the whole recipe on the next line
32

43
// This program should log out the title, how many it serves and the ingredients.
54
// Each ingredient should be logged on a new line
65
// How can you fix it?
7-
//by using the string literal to ensure multiple lines, then having the title on the first line, the number served on the next line and ingredients on the third line. using the dot notation to access the properties needed.
86

97
const recipe = {
108
title: "bruschetta",
119
serves: 2,
1210
ingredients: ["olive oil", "tomatoes", "salt", "pepper"],
1311
};
1412

15-
console.log(`${recipe.title} serves ${recipe.serves}
16-
ingredients: ${recipe.ingredients[0]}
17-
${recipe.ingredients[1]}
18-
${recipe.ingredients[2]}
19-
${recipe.ingredients[3]}`);
13+
console.log(`${recipe.title} serves ${recipe.serves}
14+
ingredients:
15+
${recipe}`);

0 commit comments

Comments
 (0)