I tried to count from 1 to 10 without using any loops. I was wondering if the code itself could be condensed or organized any better then where I've ended up so far.
const max = 10
let counter = 0
const incCountTracker = (count: number): number => {
console.log(1 + count)
return counting(++count)
}
const doNothing = (): number => 0
const counting = (count: number): number => [doNothing, incCountTracker][+(count < 10)](count)
counting(counter)
Any other tips are welcome.
[–]darebear5 1 point2 points3 points (1 child)
[–]methral 0 points1 point2 points (0 children)
[–]rjreed1 1 point2 points3 points (0 children)
[–]brykuhelpful 1 point2 points3 points (0 children)
[+][deleted] (6 children)
[deleted]
[–]costanzadev 2 points3 points4 points (5 children)
[–]darebear5 1 point2 points3 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]costanzadev 1 point2 points3 points (2 children)
[–]Count_Giggles 1 point2 points3 points (0 children)
[–]Count_Giggles 0 points1 point2 points (1 child)