Probleme exercice pierre feuille ciseaux


#1


https://www.codecademy.com/fr/courses/javascript-beginner-fr-FR-aba4j/0/4?curriculum_id=5355c2b7516bcbd912000008#

SyntaxError unexpected token {


var choixUtilisateur = prompt("Pierre, feuille, ciseau ?");
var choixOrdi = Math.random();

if((choixOrdi >= 0 ) && ( choixOrdi <= 0.33 )){
    console.log("Pierre");
}
    else if((choixOrdi >= 0.34 ) && (choixOrdi <= 0.66 )){
    console.log("Feuille");
    }
    else ((choixOrdi >= 0.67 ) && (choixOrdi <= 1 )){
    console.log("Ciseau");  
    }


#2

else statements don't have a condition
so write "else if" instead of just "else"

should be like-

else if ((choixOrdi >= 0.67 ) && (choixOrdi <= 1 )){
    console.log("Ciseau");

else use for default value or statement
if you don't need any default value or statement, dont need to write it. :slight_smile:
@megacoder81601


#3

when i dont use statment for else i have this error message which said, else must have statment 0.67 and 1.


#4

erreur d'orthographe
you just missed "x"
"Ciseaux" not "Ciseau"

console.log("Ciseau"); <= write "Ciseaux"

ok???? :slight_smile:

@megacoder81601


#5

Try this :

var choixUtilisateur = prompt("Pierre, feuille, ciseau ?");
var choixOrdi = Math.random();

if((choixOrdi >= 0 ) && ( choixOrdi <= 0.33 ))
{
console.log("Pierre");
}
else if((choixOrdi >= 0.34 ) && (choixOrdi <= 0.66 ))
{
console.log("Feuille");
}
else ((choixOrdi >= 0.67 ) && (choixOrdi <= 1 ))
{
console.log("Ciseau");
}