function createDOMNodes( page ) {
const currentArray = page === 'result' ?
resultsArray :
Object.values( favorites );
// console.log( 'currentArray' , page , currentArray );
currentArray.latest_photos.forEach( (result) => { // do something } );
}
The problem is that there is no latest_photos in the favorites object, I just want to loop the currentArray.forEach when the page parameter is 'favorites'
how can I do that?
It want to switch between different properties when the page is changed. It works fine when I remove the latest_photos property.
Is there a way to Loop through a different array when the page is changed
.forEachinstead offor( of )?resultsArray, exactly?