Currently, I am in the process of developing a website that utilizes data extracted from an API. My goal is to implement an if-else statement that dynamically changes the HTML output based on whether the result is 0, 1, 2, or 4. Is there a way to condense this logic into a single statement instead of having four separate blocks of code?
if(data.results.indexOf(element) >= 0 && data.results.indexOf(element) <= 3){
let dynamicResult = document.getElementById(`result${data.results.indexOf(element)}`);
dynamicResult.style.display = "block";
dynamicResult.innerHTML = `${element.original_title}`;
}