This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*, | |
*::before, | |
*::after { | |
box-sizing: border-box; | |
} | |
body { | |
padding: 50px; | |
color: #f7f7f7; | |
min-height: 100vh; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get details | |
const getDetails = (details) => { | |
// iterate over the detail items of object | |
for (const detail in details) { | |
// fetch the value of each item | |
if (detail == "img") { | |
markupArray.push( | |
`<img src="./img/${details[detail]}" alt="${details[detail]}">` | |
); | |
} else if (detail == "children") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const data = { | |
Parent: { | |
img: "father.png", | |
name: "Jan Doe", | |
age: "50", | |
children: [ | |
{ | |
child: { | |
img: "child_1.png", | |
name: "child 1", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get details | |
const getDetails = (details) => { | |
// iterate over the detail items of object | |
for (const detail in details) { | |
// fetch the value of each item | |
if (detail == "img") { | |
markupArray.push( | |
`<img src="./img/${details[detail]}" alt="${details[detail]}">` | |
); | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get items in the object | |
const getItems = (items) => { | |
for (const item in items) { | |
markupArray.push(`<li> ${item}`); | |
// fetch the parent object | |
let details = items[item]; | |
getDetails(details); | |
// push the closing tag for parent | |
markupArray.push("</li>"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get details | |
const getDetails = (details) => { | |
// iterate over the detail items of object | |
for (const detail in details) { | |
// fetch the value of each item | |
markupArray.push(`<span> ${details[detail]} </span>`); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get items in the object | |
const getItems = (items) => { | |
for (const item in items) { | |
markupArray.push(`<li> ${item}`); | |
markupArray.push("</li>"); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// evaluate expressions | |
const createList = (items) => { | |
switch ($.type(items)) { | |
case "object": | |
getItems(items); | |
break; | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add a parent with some details | |
const data = { | |
Parent: { | |
name: "Jan Doe", | |
age: "50", | |
img: "father.png", | |
}, | |
}; |
NewerOlder