'i want the function of for loop to perform one by one when a key or mouse is pressed
<div id="text">Nature in the broadest sense is the physical world or universe</div>
let el = document.getElementById(text);
let eltext = el.innerText;
let final = eltext.split(" ");
let i;
for (i = 0; i < final.length; i++) {
if (final[i] === "the") {
final[i] = `<b>${final[i]}</b>`;
}
let result = (final + " ").replace(/,/g, " ");
el.innerHTML = result;
the result will be: Nature in the broadest sense is the physical world or universe
what i want: when any key is triggered for the first time: Nature in the broadest sense is the physical world or universe
when any key is triggered for the second time: Nature in the broadest sense is the physical world or universe
when any key is triggered for the third time again: Nature in the broadest sense is the physical world or universe
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
