I am encountering an issue with this code, as it is not functioning as intended. Although, I am unsure about the root of the problem.
Code:
<body>
var randNumForQuote = Math.floor((Math.random() * 11));
if (randNumForQuote == 0) {
document.getElementById("quoteDiv").innerHTML = "Hello";
} else if (randNumForQuote == 1) {
document.getElementById("quoteDiv").innerHTML = "Hello1";
} else if (randNumForQuote == 2) {
document.getElementById("quoteDiv").innerHTML = "Hello2";
} else if (randNumForQuote == 3) {
document.getElementById("quoteDiv").innerHTML = "Hello3";
} else if (randNumForQuote == 4) {
document.getElementById("quoteDiv").innerHTML = "Hello4";
} else if (randNumForQuote == 5) {
document.getElementById("quoteDiv").innerHTML = "Hello5";
} else if (randNumForQuote == 6) {
document.getElementById("quoteDiv").innerHTML = "Hello6";
} else if (randNumForQuote == 7) {
document.getElementById("quoteDiv").innerHTML = "Hello7";
} else if (randNumForQuote == 8) {
document.getElementById("quoteDiv").innerHTML = "Hello8";
} else if (randNumForQuote == 9) {
document.getElementById("quoteDiv").innerHTML = "Hello9";
} else if (randNumForQuote == 10) {
document.getElementById("quoteDiv").innerHTML = "Hello10";
}
<div id="quoteDiv"></div>
</body>
My knowledge in JavaScript is limited, which makes it challenging for me to pinpoint the issue.
I anticipate the div to display one of the potential outputs (e.g., Hello, Hello1, Hello2, etc.
)