Ad
  • Custom User Avatar

    I agree on this - I had originally put the condition for length in the spin word function as well for the sake of prettier code in the main function. The lack of seperation of duties ended up bugging me too much so I pulled the condition back into the return of the main function. This makes the spinSingleWord function more useful in other functions as it is as you have mentioned agnostic to the logic it just does the job. If you were add in another function to futher abstract the logic, I would probably have it take the length after which to spin the word as an argument.

  • Custom User Avatar

    Object.keys(needs).map() returns array, so then it's destructured to feed values into Math.min()

  • Default User Avatar

    What does the ...Object here do? I've just seen the three dots in destructuring of arrays like const [head, ...tail] = my_array.

  • Default User Avatar

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

  • Default User Avatar

    You could have omitted a few unnecessary blank characters to improve further!

  • Default User Avatar

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

  • Default User Avatar

    Very, very helpful indeed, could not make sense of this solution myself. The trick really is that the person does not think about "tokens" in the sense of "whole words", but rather simply searches for strings like "_f" or "-F" or "_b" or "_B" etc.