javascript - Adding multiple parameters to an else if statement? -
let me explain in more detail, i'm making little sketch maths teacher calculate missing sides , angles of triangle. have if/else/else if statements want else if statement output "check spelling" if none of other statements true. basically, want something (keep in mind don't know how program yet)
// more code above else if (side != "hypotenuse , adjacent"; "hypotenuse , opposite"; "opposite , adjacent") { confirm("please check spelling."); }
can see trying do? previous variable called side , prompts user input sides of triangle have, sketch can work out angle. if have spelling mistake , doesn't match of parameters set, how make follow out block of code if don't match? may have over-complicated things here if tell me how this, appreciated
you can try indexof
:
possibilities = ["hypotenuse , adjacent", "hypotenuse , opposite", "opposite , adjacent"] // if side not in array (the same not in of values) if (possibilities.indexof(side) == -1) {}
Comments
Post a Comment