i´m getting crazy with this...I need to loop 10 times (automaticaly) a random number between 1-4 (both included), and this numbers must obtain a colour from switch cases', printed in the console.I tried to separate the switch cases, random function & the loop of that random function but....Any suggest???
//colours to assiged(depending on random number)
function getColor(colorNumber=0)
{
colorNumber = parseInt(colorNumber);
switch(colorNumber){
case 1: return "red";
break;
case 2: return "yellow";
break;
case 3: return "blue";
break;
case 4: return "green";
break;
default: return "black";
break;
}
}
//var with random generated
function getAllStudentColors(){
var getAllStudentColors = Math.floor(Math.random(4-1)*10) + 1;
}
//looping for function of random numbers
function loop() {
var exampleColor = 0;
while (exampleColor = 1) {
getAllStudentColors();
exampleColor++;
}
}
var exampleColor = getColor();
getAllStudentColors();
Aucun commentaire:
Enregistrer un commentaire