Tell us what’s happening:
When running the tests I get the following:
Cannot read property 'reduce' of undefined
Cannot read property 'reduce' of undefined
Cannot read property 'reduce' of undefined
Cannot read property 'reduce' of undefined
Cannot read property 'reduce' of undefined
Cannot read property 'reduce' of undefined
Cannot read property 'reduce' of undefined
Cannot read property 'reduce' of undefined
Which suggests that the rules argument I’m being supplied is not an Array. The list of test cases on the left also suggests something is wrong with the system, providing entries like the following:
'genFizzBuzz('+JSON.stringify(tests[0][0])+','+tests[0][1]+')should return a type.'
So…how do I advance under these circumstances?
Your code so far
function genFizzBuzz (rules, num) {
return rules.reduce((prev, [mult, str]) =>
prev += (num % mult === 0) ? str : ''
, '');
// Good luck!
}
console.log(
genFizzBuzz(
[ [3,"Fizz"] , [5,"Buzz"] ]
, 15
)
)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/coding-interview-prep/rosetta-code/general-fizzbuzz