(Solved) Filtering an array on multiple locations

I have multiple locations on a map and a repeater. I would like to show a clicked location on a repeater on the map. There seems to be an error in my code;

export async function text89_click ( event ) {
let lon = $w ( ‘#repeater1’ ). data . find ( e => e . _id === event . context . itemId ). longitude ;
await getLocations (). then (( locations ) => {
let markers = [];
for ( let i = 0 ; i < locations . length ; i ++) {
let loc = locations [ i ];
let search = ( loc , text ) =>
loc . filter ( i => i . longitude );
let result = search ( loc , lon );
markers . push ({ title :${ result . name } \n ${ result . addr1 } \n ${ result . phone } \n ${ result . web } \n , position : { lat : result . latitude , lng : result . longitude }});
console . log ( result )
}
$w ( ‘#htmlMap’ ). postMessage ({ markers });
})
}
There is no error on the page code, but on the live site’s devs console it shows there is an error on the line;

loc . filter ( i => loc . longitude );
The error is;

ys6l1.js:31 Uncaught (in promise) TypeError: t.filter is not a function
at ys6l1.js:31:7
at ys6l1.js:32:14

Does anyone have any idea how this can be resolved?

For anyone trying to do the same here is the correct code;
let lon = $w ( ‘#repeater1’ ). data . find ( e => e . _id === event . context . itemId ). longitude ;
await getLocations (). then (( locations ) => {
let markers = [];
let loc = locations
var output = loc . filter ( employee => employee . longitude == lon );
for ( var i = 0 ; i < output . length ; i ++){
let result = output [ i ]
markers . push ({ title :${ result . name } \n ${ result . addr1 } \n ${ result . phone } \n ${ result . web } \n , position : { lat : result . latitude , lng : result . longitude }});
console . log ( result )
}
$w ( ‘#htmlMap’ ). postMessage ({ markers });
})