Ad
  • Default User Avatar

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

  • Default User Avatar

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

  • Custom User Avatar

    Seems to have resolved itself.

  • Default User Avatar

    I keep having problems with 504 gateway timeout when I try to submit this kata.

  • Default User Avatar

    A good heuristic for deciding between the ternary operator and if/else is whether you are choosing between side effects or between calculations. For example:

    if (employee.isBoss()) {
        status = employee.notifyDirectReports();
    } else {
        status = employee.notifyBoss();
    }
    

    Here it should be clear that the choice is between two actions. Contrast with:

    pay = employee.bonusActive() ? BONUS_RATE * employee.hours() + employee.bonusAmount()
                                 : BASE_RATE * employee.hours();
    

    In this case we're choosing one of two calculations. You could rewrite the first example to use the ternary operator, but then it's easier to miss the side effects.

    There is a strong tendency for beginning programmers to want to use language constructs to make code terser and denser than it should be, without considering the factor of readability. It comes down to the question of whether you have the experience and/or discipline to use the ternary operator when it's appropriate and not just because you want to see if you can fit something on one line. If you're not disciplined enough to consider the pros and cons each time you use it, then it's best to err on the side of verbosity. The same argument holds for the ++ and -- operators and other shortcuts.

    That's not to say that you personally aren't good enough or experienced enough, but if you think about a policy that has to cover a whole company or a whole open source project, you need rules that will prevent the worst programmer in the group from writing bad code, and so you end up with more always / never prescriptions.

    One last thing: Different languages vary widely on how verbose coders tend to be. Things like the ternary operator and using short-circuiting boolean operators for side effects is much more tolerated in JavaScript, for example. The best advice is to try to match what most people are doing for your given language and platform, since it will make it easier to adapt to any given code base in that language, and easier for others to give feedback on or contribute to your code.

  • Default User Avatar

    Not quite sure how your supposed to solve this when the test case once submitted looks for a function called helloWorld. I solved it but since you updated the test cases it doesn't seem as though you can submit it?

  • Default User Avatar

    That was a fun challenge. Kept catching myself using a stray 0 or ''.

  • Default User Avatar

    You are supposed to mimic what the 'delete' keyword does, which is return false when trying to delete a non-configurable property. 'delete' is responding to you request by saying it will never delete that key, move along.

    Your interpretation would also be useful behavior, but it's not what they were looking for.

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete

  • Default User Avatar

    That was darned clever. Fun kata!

  • Default User Avatar

    I must be missing something; it seems to me that the test cases include asserting that store.delete('e') should return true, but the test code never caches anything under the key 'e'. Other than that, this was a fun challenge!

  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

    That was fun. At first I accidentally parsed the operators as right-associative instead of left... that took a while to figure out.
    Good challenge! I agree that adding exponents would be a fun extra - that way you have a combo of left-associative and right-associative operators.
    I kind of felt like the point about unary minus never having whitespace between it and a number or open-paren was a bit of a red herring - I had to get to the point of a token stream and already be parsing to be able to tell the difference between binary and unary minus. I guess I could have included whitespace in the token stream and then added strict syntax checks, but that seems out-of-scope for this kata.

  • Default User Avatar

    That was kind of stupid, I had to guess the TITLES array. It's supposed to be predefined, but it's not.

  • Custom User Avatar

    Heard lots about Monads and thinking I should learn, the description was a nice introduction with great links too. But I can't get the Kata to work. I've been trying for a while now but can't get the "Bound functions evaluated on Something" testcases correct. Bind receives a function from a value (not a Monad) to a value (a Monad), it should return a function from a value (Monad) to a value (Monad). I've been doing some logging and it seems that the testcases expect the function passed to bind to take a number x return Just(x+1). The problem is that i can't make the function passed to bind return anything else than Nothing.

    Maybe.bind = function(f){
      console.log(f(1) instanceof Nothing);
      console.log(f(Just(1)) instanceof Nothing);
      ....
    }
    

    Only logs 'true'

    I probably missed something crucial here but I can't understand what the function f is or what I'm supposed to do with it.

  • Loading more items...