So I'm learning javascript and decided to do the ping pong test challenge. Basically you it prompts you a number and displays all the numbers except "ping" for multiples of 3, "pong" for multiples of 5, and "ping-pong" for multiples of 15. I got it to work, but for some reason it displays an empty list after every 5th index. I don't know why this is, and so hopefully I can get some help with this and some explanation. Here is my code:
<!DOCTYPE html>
<html>
<head>
<script src="epicodus/js/jquery-1.11.2.js"></script>
<script src="epicodus/js/ping-pong.js"></script>
<title>Ping Pong Test</title>
</head>
<body>
<ul id="list">
</ul>
</body>
</html>
$(document).ready(function() {
var number = parseInt(prompt("What number would you like me to ping-pong up to?"));
for(index = 1; index <= number; index += 1) {
if (index % 15 === 0) {
$("#list").append("<li>" + "ping-pong" + "</li>");
} else if (index % 3 === 0) {
$("#list").append("<li>" + "ping" + "</li>");
} else if (index % 5 === 0) {
$("#list").append("<li>" + "pong" + "<li>");
} else {
$("#list").append("<li>" + index + "</li>");
}
}
});
Also, do for loops in javascript require a semi-colon after closing the loop?