`Dear guys, i am desperately wondering why my filter function does not work while sort function works well.
code is as below,
const endpoint = 'https://gist.githubusercontent.com/Miserlou/c5cd8364bf9b2420bb29/raw/2bf258763cdddd704f8ffd3ea9a3e81d25e2c6f6/cities.json';
let cities = [];
fetch (endpoint)
.then (jsonout => jsonout.json())
.then(pushdata => cities.push(...pushdata));
let sortgo = cities.sort((a,b) => {
let firstone = a.population;
let nextone = b.population;
firstone > nextone ? -1 : 1;
});
let gofilter = cities.filter(n => n.population > 100000);
with the code above, when i do console.table(sortgo) in browser(f12), it shows cities in the order of population very well.
but when i console.table(gofilter) , it just returns undefined.. seeking for your help on this, thank you.
*attached is how json data looks like.enter image description here
I was trying to filter json data whose population is over 100000.`