Most of the code in JS gets nested because of the various conditions one has to handle for the solution. Ternary operator is the best and most common way to replace your “if…else” statements. Switch case statement is not the best possible way to. replace nested ‘if-else’ statements but these can be used to reduce. duplicate code which is another common mistake ignored by developers.
4 Comments
Sort: