I have got little problem. I\'m learning javascript and I wanted to create random slogan generator for my site with using switch
.
So I created this html
You left part of the code outside the rndqu()
function.
I forked and corrected your fiddle here:
http://jsfiddle.net/BwJ7s/
Here's the corrected JS code:
var qu;
var slogan;
function rndqu(n)
{
var random = function(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
};
qu = random(1, 3);
switch(qu){
case 1:
slogan = "Here is the 1";
break;
case 2:
slogan = "Here is the 2";
break;
case 3:
slogan = "Woah";
break;
default:
slogan = "Really?";
}
document.getElementById("quote").innerHTML = slogan;
}