I'm listing numbers from 1 to 15 and checking if the number is divisible by 3
and 5
by adding a text when true, so far it works, but only that it still displays the number under the text, how do I change the number for the text. I already used replace without success:
var nums = $(".nums");
for(var i=1; i<16; i++) {
if(i % 3 == 0) {
var tres = i;
tres = "Divisível por 3";
nums.append(tres+"<br>");
} else if(i % 5 == 0) {
var cinco = i;
cinco = "Divisível por 5";
nums.append(cinco+"<br>");
}
nums.append(i+"<br>");
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><divclass="nums"></div>