Test case details

Preparation Code

const data = Array.from({length: 1000}, () => { const latNull = Math.random() < 0.1 const lonNull = Math.random() < 0.1 return { lat: latNull ? null : Math.random(), lon: lonNull ? null : Math.random(), other: new Date().toString() } });

Test cases

Test #1

data.reduce((acc, item) => { if (!item.lat || !item.lon) return acc; return [...acc, [item.lon, item.lat]] }, [])

Test #2

data.filter(item => item.lat && item.lon) .map(item => [item.lon, item.lat])