I have a unique program that extracts data from 2 different URLs. Using CSS, I automatically generate a sleek Business Card design in a 'for' loop. Now, I'm faced with the challenge of creating a Sort Alphabetical button based on "${users[count].name}" and frankly, I'm stumped on how to tackle this.
Promise.all([
fetch('https://jsonplaceholder.typicode.com/photos'),
fetch('https://jsonplaceholder.typicode.com/users')
]).then(function (responses) {
return Promise.all(responses.map(function (response) {
return response.json();
}));
}).then(([ photos , users]) =>{
var names = document.getElementById('names')
for (let count = 0; count < 10; count++){
names.innerHTML+=`
<div class= "profile_card">
<div class=topCont>
<img class="thumbnail" src="${photos[count].thumbnailUrl}">
<div class="personal">
<h2 class="name">${users[count].name}</h5>
... etc
</div> </div>
`
Following that, there are some EventListeners involved, but I don't believe they are relevant to my current dilemma. The main issue at hand is figuring out how to organize and store all the printed data in an Array so that I can implement a sorting mechanism. One idea that crossed my mind is utilizing a 'for' loop from 0 to 10 to display them based on ascending order or another criteria.