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()