Any idea where im going wrong?

Any idea where im going wrong?
0

#1
newOne === "zero" ? (newInput = 0) : (
        newOne === "one" ? (newInput = 1) : (
          newOne === "two" ? (newInput = 2) : (
            newOne === "three" ? (newInput = 3) : (
              newOne === "four" ? (newInput = 4) : (
                newOne === "five" ? (newInput = 5) : (
                  newOne === "six" ? (newInput = 6) : (
                    newOne === "seven" ? (newInput = 7) : (
                      newOne === "eight" ? (newInput = 8) : (
                        if (newOne === "nine") ({newInput = 9})
                      )))))))));

quick overview: this is for the calc project. all the variables are initialized and working fine. Its throwing a syntax error. saying unexpected token at the end of the whole thing.


#2

May be this ({newInput = 9}) should be this :point_right: (newInput = 9) .


#3

Um, use if...else or switch or anything except nested ternaries for starters, this is unbelievably hard to read and nearly impossible to debug: see your question as an example. A good rule of thumb is never ever, ever, ever nest ternaries.


#4

haha yea thats fair. i was actually going to use a switch statement but this was more fun haha.