Ad
  • Custom User Avatar

    Thanks for introducing me to the stream methods available, really nice pattern.

  • Custom User Avatar

    that's normal initialisation of variables, the data type doesn't matter
    makes the code more compact

  • Custom User Avatar

    There's no need to compare with the empty string, since the outer loop will never be entered when str.length is 0 (becase 0 < 0 evaluates to false, the whole loop is skipped)

    The issue with this code is you're returning 'true' before the outer loop has a chance to iterate, so you never compare the second letter with the rest of the string.

    Move 'return true' down one line so it's the last thing that happens in the function and you will pass the tests without your str === ''

  • Custom User Avatar

    I was able to pass the tests from copy pasting your code so I can't speak to what the difference is, but I noticed you have a spurious global 'x' when you pass index + 1 to arrString.includes(). It works because the "x = index + 1" returns the new value of x, so its equiveleant to just "index + 1"

  • Custom User Avatar

    Nice, thank you for teaching me that there is a rotate function

  • Custom User Avatar

    is it best practice to assign variables like this, when i and ys are different data types? I guess I can get used to it but it was confusing to look at at first.

  • Custom User Avatar

    I like the use of slicing here in names[2:], I think it is more clear what you are counting then other solutions with len(names) - 2, which feels a little magic numbery.

  • Custom User Avatar

    I like the use of slicing here in names[2:], I think it is more clear what you are counting then other solutions with len(names) - 2, which feels a little magic numbery.

  • Custom User Avatar

    Good to know for/in works on strings, but performing regex is iterating over the whole string, so this becomes exponential time complexity.