3 ms·
If you replace the ternary with an if then it's easy to understand for anyone who knows what ... means (which imo every JS developer should know) const count
by mitt_romney_12 3y ago
If you replace the ternary with an if then it's easy to understand for anyone who knows what ... means (which imo every JS developer should know)
const count = (amount: number) => {
if (amount > 0) {
return [...count(amount - 1), amount]
} else {
return []
};
}
- reactordev 3y agoYou missed the point entirely I’m afraid. It’s not about replacing the if with …, it’s about complexity.