Issue with wix code for dropdown search.

Hello, I wrote a block of codes to create two dropdowns on my wix website and two buttons, one to search the other to reset the selection, when I tested the website the result from the website comes out buggy. Some information is missing that’s meant to be displayed. I don’t know what to do. I really need your help to sort this out, here is the code

import wixData from ‘wix-data’ ;
let filter = wixData.filter();

$w.onReady(() => {
for ( let i = 0 ; i < 2 ; i++) {
filter.filterTree.$and[i] = {}
}
})

export function button2_click(event) {
$w( “#dataset4” ).setFilter(wixData.filter())
$w( “#dropdown5” ).value = “null” ;
$w( “#dropdown6” ).value = “null” ;
$w( ‘#resultTxt’ ).hide();

} 

if ($w( ‘#dropdown5’ ).value.length === 0 ) {

    filter.filterTree.$and[ 3 ] = {} 

}  **else**  { 

    filter.filterTree.$and[ 3 ] = {  "statesLicensedToPracticeIn" : $w( '#dropdown5' ).value };  

} 

if ($w( ‘#dropdown6’ ).value.length === 0 ) {

    filter.filterTree.$and[ 4 ] = {} 

}  **else**  { 

    filter.filterTree.$and[ 4 ] = {  "therapueticSpecializations" : $w( '#dropdown6' ).value };  

}  

console.log(filter) 

$w( “#dataset4” ).setFilter( wixData.filter() );