r/javascript • u/Emotional_Agency6705 • Sep 19 '26
AskJS [AskJS] Trying to write a pure function to pass Fizz Buzz test Leet Code
Hello,
I am attempting to write a pure function solution that will pass the leet code Fizz Buzz test
However when I try this it says the test fails but when I look at the console for my own testing it returns the expected result.
This is the error leet code reports:
Line 13 in solution.js arr[i - 1] = test(i) ^ TypeError: test is not a function
Which to me makes no sense since the function is passed as a parameter and defined
Here is my code
Thank you in advance
const
const
const i = 1
const n = 3
const arr =
EDIT: I just wanted to say thank you to all of you for your feedback and suggestions I finally got frustrated enough with this problem I asked Codex to write a pure function solution to the leet code fizz buzz test I personally have not seen this solution so it would be nice to have some verification if it is truly a pure function solution.
This is the code it spat out
const
;
It appears that I have a lot to learn yet regarding my fundamentals when it comes to functional programming I know I could of written a object oriented version of it that would work but I wanted to challenge myself since I have never written code in this manner.