Ad
  • Custom User Avatar

    jsfiddle only calls your function once. CW calls your function multiple times. That's the difference.

    Think about what happens when your function is called the second time ;-)

    Edit: Even better, don't just put 1 function call on your jsfiddle. Put multiple of them, in the exact way the tests in CW are done ;-)

  • Custom User Avatar

    Better than me explaining it, why don't you try calling your function several times and checking the result?

  • Custom User Avatar

    Already told you before, the global var (count) keeps its value between tests, giving you wrong values after the first call.

  • Default User Avatar

    Variable "b" inside "reducer" function must be integer, so you can use a * parseInt(b),
    you can delete for loop, keep if-else statement.
    Also "reduce" need initial value (1 in your case).
    Hint: you should use "return" on two places (becouse of recursion).

  • Custom User Avatar

    Don't use global vars, they keep their values between tests.
    Your function doesn't return.

  • Custom User Avatar

    No problem. Now after you've done it your way, I suggest you see how other people solved it and learn different ways of doing it.

  • Custom User Avatar

    Debug your code for that case then. If you still have the same problem, you're not using reduce the right way.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Remove the if and read this

  • Custom User Avatar

    Simplify your code, why are you trying to use a promise here? You're trying to use some complex things without needing them. You have like 6 loops there and this kata can be solved with only one.
    Return 0 if no multiple of 3 or 5 is found.

  • Custom User Avatar

    My guess is you're counting the number passed in too when it says:

    Finish the solution so that it returns the sum of all the multiples of 3 or 5 below the number passed in.

    There is only one sample test after all.

  • Default User Avatar

    Hi, you probably encountered certain edge case. You can paste your solution here (with spoiler) and someone who finished this kata earlier can see your solution and try to help.