The problem is how do you know what the piece of data that is invalid age or username or something (you need to have additional code). And what if you want to throw custom error message for each case?
Array in JS is also weird (if you dont know the spec of map or using Typescript)
a=[].map(v=>v.v.v.v.v.v)// it is valid
It can cause debuging becomes nightmare!
So I prefer if-else.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The problem is how do you know what the piece of data that is invalid
age
orusername
or something (you need to have additional code). And what if you want to throw custom error message for each case?Array in JS is also weird (if you dont know the spec of
map
or using Typescript)It can cause debuging becomes nightmare!
So I prefer
if-else
.