Ad
  • Custom User Avatar

    This challenge is as old as Codewars itself. There were no mods 12 years ago. It was approved and ranked by the author of Codewars.

  • Custom User Avatar

    Maybe, instead of thinking how to change the function without changing the function, start thinking about why and how the unittest fails in the first place. This will help you come up with a solution.

  • Custom User Avatar

    The whole point of the Kata was to show that you can in fact change the behavior of the function from outside using JavaScript.

    But you need to take a few steps back and think about how JavaScript actually works and which peculiarities it has. The function looks simple, but how does JavaScript execute it actually?

    I do not want to give too many clues. If you can't come up with a solution, simply skip it.

    Just be aware that in real life as a programmer you sometimes also have such "mysteries" where you think "it can't be", until finally you understand that you overlooked something that is important that might influence the behavior of your program. Or something that you simply never knew or imagined your programming language or library would do under the hood.

  • Custom User Avatar

    I do not know why you call this "opinion". This particular challenge has a solution (which you said is impossible) and the solution is a single line of pure JS without calling any native functions or messing with runtime or anything of this kind (which you say would be necessary). So how is it that there is 1100 solutions and none of them does any native mumbo-jumbo and does not rewrite code at runtime and does no runtime specific shenanigans. It's 6 kyu, it uses very basic mechanisms of the language. JavaScript is not a pure, side-effects-free language, and behavior of a JS function can be affected by many factors, including other places in the program, and not just by how the function is written. That's how bugs are done.

    There is no need to be bitter over a challenge which you don't like. It's a puzzle, not everyone has to like puzzles, and anyone who does not like puzzles can just move along. But being unable to solve it and getting all grumpy because of that and throwing tantrums is just lame.

  • Custom User Avatar

    approved

  • Custom User Avatar

    This is very wrong.

  • Custom User Avatar

    Yes, it's possible. It's strange that a programmer would think that modifying one piece of code somewhere couldn't possibly have the effect of changing the behavior of different code in a different location.

  • Custom User Avatar

    I would tell you that I just completed the challenge so it seems pretty possible, but since this does not matter, then I won't.

  • Custom User Avatar
  • Custom User Avatar

    Well, this challenge is a puzzle, and getting to the solution without changing the function is a part of the puzzle.

    If you do not like puzzle kata (like me), you can just go to another one.

  • Custom User Avatar

    me two man , i solve it in the old fashion to find someone did it

  • Custom User Avatar

    Ha, this is a short one. You should see a couple C++ katas I solved with Nim. iirc, generated code was 800+ lines.

  • Custom User Avatar

    approved, if you want to make some more changes, suggest a new fork

  • Custom User Avatar

    approved

  • Custom User Avatar

    yes

  • Loading more items...