I have seen this multiple time :
if (...) { // the condition is not important in this example
return 'toto'
} else {
return 'tutu'
}
If your if return value you can just replace the code above by :
if (...) { // the condition is not important in this example
return 'toto'
}
return 'tutu'
hey thanks for your comment, yes it's working in case of you only need to return something! If you add more logic in the if or after you cannot use ternary (unlike you create function).
The other point is about else if! If you need to have else if is more complicated!
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.
should it be below ?
hey thanks for your comment, yes it's working in case of you only need to return something! If you add more logic in the if or after you cannot use ternary (unlike you create function).
The other point is about else if! If you need to have else if is more complicated!