Can someone help me with sorting this image gallery by name?
Here is the HTML for the gallery:
<div>
<div id="result"></div>
</div>
And here is the JavaScript code:
const container = document.getElementById('result');
function getData() {
fetch('https://randomuser.me/api/?results=30')
.then((response) => response.json())
.then((results) => output(results));
}
function output(results) {
const htmlData = results.results
.map((result) =>
`
<div>
<img src="${result.picture.large}">
<div>${result.name.first}</div>
</div>
`
).join('');
container.innerHTML += htmlData;
}
getData();