Ingredient Substitute Finder
This is a functional but incomple substitute
finder for cooking ingredients
I will be adding ingredients here and there,
but mostly this is a proof of concept.
Main functiona
let displayIngSub = () => {
let search = input.value;
let dataDisplay = Object.values(data).filter((eventData) => {
if(search === '') {
return '';
}else if (eventData.name.toLowerCase().includes(search.toLowerCase())) {
return eventData;
}
}).map((object) => {
const {name, amount, substitute1, substitute2, substitute3} = object;
if (substitute3 === undefined) {
return`
x
Ingredient: ${name}
Amount: ${amount}
You can substitute with: ${substitute1}
or with: ${substitute2}
`
}else {
return`
x
Ingredient: ${name}
Amount: ${amount}
You can substitute with: ${substitute1}
or with: ${substitute2}
or with: ${substitute3}
`
}
}).join('');
display.innerHTML = dataDisplay;
}