Hi im trying to make the input filed case insensitive so that i can search for chicken and not Chicken.
Ill add a picture of the search bar, and ill add my code, but ive used <<<<<<< to single out the function and the calling of that function. Do i need to do something with the filter-option too and not just the input value?
Thank you. Its a bonus question but I can not let it go.
$w.onReady(function () {
// Codecademy - Called The Function <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
lowerCaseFilter();
// Pre-selected elements
const inputField = $w(‘#input’);
const dropdownElement = $w(‘#dropdown’);
const filterButton = $w(‘#filterBtn’);
const reset = $w(‘#resetBtn’);
// Add your code below
for (let i = 0; i < recipeList.length; i++) {
let currentImage = $w(`#image${i}`);
let currentName = $w(`#name${i}`);
let currentIngredients = $w(`#ingredients${i}`);
let currentInstructions = $w(`#instructions${i}`);
let currentRating = $w(`#rating${i}`);
currentImage.src = recipeList[i].image
currentName.text = recipeList[i].name
currentIngredients.text = recipeList[i].ingredients.join(', ')
currentInstructions.text = recipeList[i].instructions
currentRating.text = `${recipeList[i].rating}`
}
// Function <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
function lowerCaseFilter() {
let userInput = $w('#input').value
userInput.toLowerCase()
}
let recipeBoxes = $w('Box')
filterButton.onClick((event) => {
let filterOut = inputField.value;
let filterOption = dropdownElement.value;
for (let i = 0; i < recipeBoxes.length; i++) {
if (recipeList[i][filterOption].includes(filterOut)) {
recipeBoxes[i].collapse();
}
}
})
reset.onClick((event) => {
for (let k = 0; k < recipeBoxes.length; k++) {
recipeBoxes[k].expand();
}
})
});