Writing cleaner code by avoiding switch case and nested if in Javascript:

Praveen David Mathew
1 min readApr 14, 2022

There are ways in which you can reduce number of lines of code and make the code looks cleaner.

One way is to avoid switch statements and nested loop

for example lets see the below functions:

simple switch statements:

--

--

Praveen David Mathew

An open source advocator/WebdriverIO Projectcommiter/Postman Supernova/Postman-html-extra contributor/Stack overflow sqa moderator/Speaker