inputField.addEventListener("keyup",(e)=>{
let inputVal=inputField.value;
if(e.key==="Enter" && inputVal.length > 0){
//for(let i=0;i<inputVal;i++){
optionImages.forEach((image,index) => {
image.addEventListener("click",(e)=>{
image.classList.add("active");
userResult.src = cpuResult.src="images/rock.png";
result.textContent= "Wait..."
optionImages.forEach((image2,index2)=>{
if (index!=index2) {
image2.classList.remove("active");
}
});
gameContainer.classList.add("start");
});
});
//}
}
});
I want the code to run as much as the value entered from the input, but when I do it with a for loop, the foreach part continues to run forever.