I would suggest 4 improvements (3 minor and 1 critical)
Critical bug
1) Provide the fidelity parameter as argument to the function, otherwise will only have a value other than 2 in the first step of the recursion;
Minor suggestions
1) Reduce LOC by decreasing by one in the if statement;
2) Remove obsolete else branch;
3) No need to reassign the variable, just return the result right away;
How’s it going, I'm a Adam, a Full-Stack Engineer, actively searching for work. I'm all about JavaScript. And Frontend but don't let that fool you - I've also got some serious Backend skills.
Location
City of Bath, UK 🇬🇧
Education
10 plus years* active enterprise development experience and a Fine art degree 🎨
Array from with a function callback isn't as fast as mapping an empty array from an Array constructor. 🤣
It's not the point that it's buggy, it's important that you can take my crappy code and make something better, success. Still the failure to pass args recursively is something il fix.
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.
I would suggest 4 improvements (3 minor and 1 critical)
Critical bug
Minor suggestions
BTW sorry if I sound picky...
Array from with a function callback isn't as fast as mapping an empty array from an Array constructor. 🤣
It's not the point that it's buggy, it's important that you can take my crappy code and make something better, success. Still the failure to pass args recursively is something il fix.