Ad
  • Default User Avatar

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

  • Default User Avatar

    i did the same thing and it didnt work, so i just solved it the long way

  • Custom User Avatar

    There's no guideline saying how many return statements you should have. There used to be one, but in modern languages it's no longer applicable. The only practice is that control flow of your function should be clear, what means you should consider structure of your ifs, loops, try/catch blocks, their nesting, and, eventually, returns inside of them. But it's not a matter of numbers, but rather of layout.

    It's perfectly valid to exit a function upon verification that it should not, or does not have to, perform any further work.

    Besides, in your solution you have other things to worry about than an early return :)

  • Custom User Avatar

    Trust me it's kind of hard to understand what you are trying to point out, however I see your point through this code. This code work and well done!

  • Custom User Avatar

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