Hey there,
I've been struggling with a bug and despite multiple attempts, I can't seem to find a solution :(
I want a month to be displayed when clicked, and then on another click, a different month should appear without repeating the previous one.
Here's what I have so far:
As a beginner, I tried searching on Google but couldn't find an answer to my question.
function randomMonth() {
var months = "January, February, March, April, May, June, July, August, September, November, December".split(',');
var randMonths = [];
while (months.length) randMonths.push(months.splice(Math.random()*months.length, 1)[0]);
document.getElementById("month").innerHTML = randMonths;
}
<button onclick="randomMonth()">Try it</button>
<p id="month"></p>
Thank you for your assistance :)