mardi 30 mars 2021

I'm trying to make a code that randomly generates either 'yes' or 'no' [duplicate]

My current code is

function RNG(){
var y = Math.random();
if(y < 0.5){
x = 1
}
if(y > 0.5){
x = 0
}
console.log(x)
}


RNG()
if(x = 1){
document.writeln('Yes')
}
else{
document.writeln('No')
}

to randomly generate text that says either yes or no, it always comes up with a different number, but always writes yes. (Using purejs)




Aucun commentaire:

Enregistrer un commentaire