I am relatively new to JavaScript and I need help with a concept.
So, I have written up something such that, for example, inside the HTML file, I have a div with id called "GetID" which is where I want to display my string outputs.
Inside the JavaScript is such code that
for(looping through data) {
if (Condition 1){
document.getElementById("GetID").innerHTML = "Yellow"
}
else if (Condition 2){
document.getElementById("GetID").innerHTML = "Red"
}
}
My question is, how do I display the next condition besides the previous one instead of replacing it every time inside the div?
For example, if the loop runs, and first and second condition is Yellow, third is Red, I want it to display "Yellow, Yellow, Red" Right now, it keeps replacing it such that, Yellow, then Yellow, then Red - only 1 string output in same div ID, replacing the previous output