Ad
  • Custom User Avatar

    Only one mistake: The index replacer callback parameter is not really the index, is the offset inside whole source string (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_function_as_a_parameter)

    So, algorithm fails if string doesn't start with a letter.

  • Custom User Avatar

    There is always something to improve, right? As said earlier I like the solution, and it taught me a couple of things. So you have my thanks.
    On that redundancy, color me old school, which is totally correct, but it is hard for me to "pack" the return statement with a bunch of code. Since most of my coding experience is coming from the early 90's late 80's, I was trained to separate stuff like that into variables and keep the return statement "light", or as "light" as possible. I'm still adjusting to what would be Best Practice. What I churn out in those Katas would be viewed as verbose and WET by the popes of Regexp and elliptic I see on Codewars.

  • Custom User Avatar

    Agree, it's better to define new variable like minorWordsArr to store array of minor words, and also now I see that title = title.toLowerCase(); is redundant statement, this transformation should be moved in return statement (like this: return title.toLowerCase().replace(...

  • Custom User Avatar

    This is pretty nifty, except for modifying the arguments.