we get objects and not arrays, return them appropriately.
This commit is contained in:
parent
3393d2015f
commit
0fef44225f
|
|
@ -233,9 +233,9 @@
|
|||
function filterTracks() {
|
||||
const query = document.getElementById('track-search').value.toLowerCase();
|
||||
const filtered = tracks.filter(track =>
|
||||
(track.title[0] || '').toLowerCase().includes(query) ||
|
||||
(track.artist[0] || '').toLowerCase().includes(query) ||
|
||||
(track.album[0] || '').toLowerCase().includes(query)
|
||||
(track.title || '').toLowerCase().includes(query) ||
|
||||
(track.artist || '').toLowerCase().includes(query) ||
|
||||
(track.album || '').toLowerCase().includes(query)
|
||||
);
|
||||
displayTracks(filtered);
|
||||
}
|
||||
|
|
@ -244,9 +244,11 @@
|
|||
function sortTracks() {
|
||||
const sortBy = document.getElementById('sort-tracks').value;
|
||||
const sorted = [...tracks].sort((a, b) => {
|
||||
const aVal = a[sortBy] ? a[sortBy][0] : '';
|
||||
const bVal = b[sortBy] ? b[sortBy][0] : '';
|
||||
return aVal.localeCompare(bVal);
|
||||
/* const aVal = a[sortBy] ? a[sortBy][0] : '';
|
||||
* const bVal = b[sortBy] ? b[sortBy][0] : ''; */
|
||||
const aVal = a[sortBy] ? a[sortBy] : '';
|
||||
const bVal = b[sortBy] ? b[sortBy] : '';
|
||||
return aVal.localeCompare(bVal);
|
||||
});
|
||||
displayTracks(sorted);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue