lundi 17 août 2020

math.random always returning 1 in array

So i ran the code about 50 times and each time it returned olg / 1 so What is wrong

alert("welcome to word unscrambler undscramble this")
console.log("i am not a distraction")
document.write("i am not a distraction either")
var r = ["pttoao","recme","logd","teey","olg"]
var g=Math.floor(Math.random() *+ 6);

if (g=="0") {select =("pttoao")}
  else if(g=="1"){select=("recme")}
   else if (g==2){select="logd"}
   else if(g==3){select="dre"}
    else if(g==4){select="olg"}
if(select=="pttoao"){realword="potato"}
if(select=="recme"){realword="creme"}
if(select=="logd"){realword="gold"}
if(select=="teey"){realword="yeet"}
if(select="olg"){realword="log"}
var awnser= prompt("unscramble "+select)
if(awnser==realword){alert("correct")
}else{
  alert("incorrect")}

maybe it is that it cant randomly select words




Aucun commentaire:

Enregistrer un commentaire