Conversation
|
Hi Mahmoud, well done. In the browser everything looks clean and the functionality is there. Nonetheless, there is always room for improvement. Thus, some feedback:
function createContentPage(parentObject) {
//loop
}
createContentPage(bookDetails)
function loopNestedObjec(parentObject) {
for (const childObject in parentObject) {
for (let i = 0; i < Object.keys(parentObject[childObject]).length; i++) {
console.log(Object.keys(parentObject[childObject])[i] + ' :\t' + Object.values(parentObject[childObject])[i])
}
}
}
const books = {
book1: {
bookTitle: 'Forty laws of love',
language: 'Arabic',
author: 'Elif Şafak'
},
book2: {
bookTitle: 'Alchemist',
language: 'Arabic',
author: 'Paulo Coelhho'
}
}
loopNestedObjec(books)
/*
prints:
bookTitle : Forty laws of love
language : Arabic
author : Elif Şafak
bookTitle : Alchemist
language : Arabic
author : Paulo Coelhho
*/
|
|
Dear Sil, Thank you very much for the efforts you did in reviewing my homework. I will revisit my homework and try to apply the points you illustrated. For the semicolon after functions, I thought that no need for it after functions. It seems that I am mistaken. |
|
Hi Mahmoud, you are correct regarding the semicolon, it's indeed not required. My bad. It's only required if you write a function as an expression statement, and yours was not written like that. For more info check: |
No description provided.