Ad
  • Default User Avatar

    read more on this correct me if i'm wrong but the second argument (array.fill) is the initial value that the reduce method is being applied to

  • Default User Avatar

    i have a question/comment about this (sorry please humor a beginner)
    i get that you're adding next to the lowest prev
    i've just only seen reduce containing one function returning a single numeric value so this is my first exposure to a second argument being passed to the method
    is the idea that by using return prev in the function followed by array fill, it's sort of doing a micro-level reduction and replaces an index in the fill array?

  • Default User Avatar

    you need to test by passing something more complex to the function besides ABC. songDecoder("AWUBWUBWUBBWUBWUBWUBC"); This will help you understand why you're getting errors.

  • Default User Avatar

    can't say for sure. might have something to do with this- "when using a regexp you have to set the global ("g") flag;"

  • Default User Avatar

    I had the same problem at first. You've got to test using a version that has consecutive WUBs. I suggest testing this by passing "AWUBWUBWUBBWUBWUBWUBC" to the function so that you can see where the additional spaces are coming from and how to remove them.