I search for the word "i" in the text, but it only shows the first "i" and does not show the rest of "i" I want you to show me the whole text though Help me please
const searchItem = () => {
const source = "Lorem ipsum dolor sit amet consectetur adipisicing elit."
const searchDate = "i";
for (let i = 0; i < source.length; i++) {
let res = source.search(searchDate);
if (res > 0) {
document.getElementById("demo").innerHTML = res;
} else if (res < 0) {
document.getElementById("demo").innerHTML = "No results found";
}
}
}
<button onclick="searchItem()">Try it</button>
<p id="demo"></p>