I need help filtering a query using code

I have queried a dataset on the backend (the reason is I needed to bypass permissions as my dataset is linked to PrivateMembersData). I store this result into “originalRows” which is accessible at the top of the page for all methods.

I then want to filter by a dropdown and using console I have found that the issue is in my if-statement of the filterResults() method. My code displays the original query on the repeater perfectly. I want to filter by “Position”. Here is my code:

function filterResults (){
let pos = $w ( ‘#positionDropdown’ ). value ;
console . log ( originalRows );
console . log ( “pos” );
console . log ( pos );
if ( pos && pos !== $w ( ‘#positionDropdown’ ). placeholder ) {
console . log ( “inside if statement” );

    filteredRows  =  originalRows . filter ( item  =>  item . position . _id  ===  pos );   //THIS IS WHERE THE ISSUE LIES - I have even used item.position without "_id", Also not working. 
    
} 

console . log ( "res" ); 
console . log ( filteredRows ); 	//THIS RETURNS NOTHING 
**return**  filteredRows ; 

}

I have another method that does the “onChange” of the dropdown to execute this above method. Why is the row in the if-statement not working? I am having syntax issues I think.

Can you show me the originalRows array?

@bwprado what do you want to see exactly?
I currently created it above the onReady functions as:
let originalRows;

I had it as:
let originalRows = ();
But this wouldn’t let me populate originalRows as it does now.

@kscholiadis I just want to know the properties of the objects inside originalRows . If you are trying to filter a property that does not exist, the filteredRows is going to return empty.