How do i make a if statement inside an if statement (Lesson 6)


#1



I have tried typing different codes but it still won't work


#2

You just have to wrap two functions up. This is the normal syntax:

var something = 3;
if(something == 3){
  if(true){
    console.log("Double If Statement Completed!")
  }
}
else{
 console.log(":(")
}

If you are still facing problem, show code please.


#3

I understand now but there is a syntax error:frowning:
Syntax error illegal return statement.

var compare = function(choice1, choice2) {
if (choice1 === choice2) {
return "The result is a tie!";
}
}
if (choice1 === "rock") {
if (choice2 === "scissors") {
return "rock wins";
}
else (choice2 === "paper") {
return "paper wins";
}
}


#4

Many mistakes there... but ima give you hints.

1: An Else statement is not suppose to have conditions...
2:Some Code for some reason are out of the function
3: To Solve your problem, As you merge everything in that function you will be faced with an else if.. then you can nest an if/else statement under that.
@njmisa


#5

Thanks, i appreciate your time and effort for helping me.