searchBtn.addEventListener('click', () => {
const para = document.createElement('p');
section.appendChild(para);
for(i=0; i < database.length; i++) {
if(searchInp.value === database[i].en || searchInp.value === database[i].tr) {
para.textContent = `${database[i].en} = ${database[i].tr}`;
} else {
para.textContent = 'Not found!';
}
}
searchInp.value = '';
})
In the code above I can’t get the string ‘Not found!’ printed out when the value I enter into the input field doesn’t match with the one in database. What am I missing here? That is not the first time I am having this issue with the else
part.