Ad
  • Custom User Avatar

    I have updated the translation. I updated the casing, but I kept using gearBox since the kata description for csharp has it as two words. I added an additional test case to check for if and ?;. I also updated the description to not mention extension methods for the javascript version and for the return value to be null instead of -1.

  • Custom User Avatar

    This is a cool kata and I think a JS translation is worthwhile. A few pieces of feedback before approval:

    Identifiers should be camelCased - e.g. dot property access down the entire chain should be car.engine.gearbox.numberOfGears. Note particularly that "gearbox" is a single word and so the camel-cased version is gearbox, not gearBox. The function GetNumberOfGears(car) should be camel-cased, and the car parameter is superfluous and should be removed.

    As per the guidelines,

    Do not use requirements which cannot be reliably tested, enforced, or expressed in terms of a kata.

    therefore there should be a test which enforces no "if" or ternary operators in the solution. This can probably be achieved by just banning the strings 'if' and ':'.

    Tidy up the description so that for JavaScript it just doesn't mention "extension methods" at all. You already have the language conditional rendering in place for the next paragraph, so just merge the two and reword.

    I also suggest that we use null as the return value rather than -1 when the property is not found. The use of -1 is sometimes understandable in statically typed languages where we perhaps want to avoid nullability, but in dynamic JS with the additional explicit semantics of undefined and null I don't think using a particular number as a marker to represent "null-ish" is justified. This particular piece of feedback is optional; your choice as to what you want to do.

  • Custom User Avatar

    I need an approval for this translation. It's an old kata, but I thought the material matched very well for javascript too.

  • Custom User Avatar

    I was asked this question in my own interview for my current job 5 years ago. I liked it so much I decided to make Katas from the memorable ones.

  • Custom User Avatar

    I don't know if this is clever or a best practice. I just wasn't aware that you could do this with template literals.

    Now, as to what is a best practice?

    I don't think it is a best practice to support outdated browsers. Not everyone wants or can afford to support everything under the sun. The kata is run on node, and if what you are using supports the option, then it is fair game.

  • Custom User Avatar

    this does go through the array twice

    Where does it go thru the array twice?

    After .map it's a join. Is that considered to be going thru the array?

  • Custom User Avatar

    I am glad others are saying it was difficult too!! I totally underestimated it!

  • Custom User Avatar

    I used to think this kind of code was unreadable before too, but I have gotten used to it. I would however prefer better variable names.

  • Custom User Avatar

    I don't know that this exact implementation is a popular problem (restricting the user to these particular indices), but it's a version of the two-sum problem which is a well-known problem. I wouldn't really consider what you did cheating, by the way ;)

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    I would only call this super simple if you are well versed in regular expressions. To me, it might as well be in French.

  • Custom User Avatar

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

  • Custom User Avatar

    Took me a while to get this answer. While it is very clever, I don't see how this is anywhere close to a best practice.

  • Loading more items...