Hi there!
I have a search function that uses the includes function but it is case sensitive. Can anybody help me how to make this case insensitive? Below is my code:
import {getAllRecords} from ‘backend/dataService’;
// Backend module named dataService.jsw under backend folder
let unfilteredRecords = ; // This will hold all records
$w.onReady( function () {
$w(“#repeater1”).data = ; // Clear repeater from data
getAllRecords().then((allObjects) => {
unfilteredRecords = allObjects;
// Store all records in array
$w(“#repeater1”).data = unfilteredRecords;
// Set all records to repeater
})
});
// Search button onClick event
export async function searchButton_click(event) {
let searchWord = $w(“#searchInput”).value;
$w(“#repeater1”).data = unfilteredRecords.filter(obj => obj.occasion.includes(searchWord)); // name is fieldKey is Data Collection
}
Big thanks to https://uggadugg.wixanswers.com/en/article/search-faster-using-filter-function for the search code.