7 kyu

Fix my method

1,431emporio
Description
Loading description...
Debugging
Object-oriented Programming
  • Please sign in or sign up to leave a comment.
  • C.c. Avatar

    Suggested changes to the label.

  • siebenschlaefer Avatar

    Now even your own solution doesn't pass any more.

    should check if myObject.objMethod was called
    expected { Object (objProperty, objMethod) } to have a property 'objMethod'
    expected { Object (objProperty, objMethod) } to have a property 'objMethod' of undefined, but got [Function: objMethod]
    expected { Object (objProperty, objMethod) } to have a property 'objProperty'
    expected { Object (objProperty, objMethod) } to have a property 'objProperty' of undefined, but got 'string'
    
  • yrazub Avatar

    Tests are not passed with any existing solution, something is wrong?

  • smbossco Avatar

    Anyone know what this error message is all about? "it" calls must be invoked within a parent "describe" context

    My solution passes when I try to submit, but I'm getting that message when I run the test.

    function myFunction() { var MyObject = { objProperty: "string", objMethod: function() { return this.objProperty; } } return MyObject; }

  • emporio Avatar

    So I have used Chai-JS to assert that the myObject is being utilized. Still requires more testing though.

  • Rahul_Raviprasad Avatar

    Requires more tests

  • creiner Avatar

    Could use further tests so that just making the function return 'string' doesn't solve the kata.

  • sofiia-hlyniana Avatar

    This kata needs more test cases

  • abdb Avatar

    This comment has been hidden.

  • sokolek Avatar

    This comment has been hidden.

  • XxxX88 Avatar

    you can easy cheat on this kata

  • JoshSchreuder Avatar

    A couple of issues - I think the description needs to be expanded on a little. Not to make it easier, but maybe a checklist of potential problems, like:

    Remember to check things like braces, commas, and letter case

    Also, I think the indentation is a little messed up in the initial code, not sure if this is intentional to make working out the problems more difficult, but if not it should be made more consistent.

  • eyaltra Avatar

    you dont check that one uses the method objMethod , one can pass retrieving return "string"

  • osofem Avatar

    As I can see it the solutions, some just returned "string" and passed! More tests should be added to prevent such solutions from passing!

  • bkaes Avatar

    This kata is tagged with

    • Bugs
    • Methods
    • Functions
    • Object-oriented Programming
    • Control Flow
    • Basic Language Features
    • Fundamentals

    However, I think that they're not really correct. The "code" we have to fix is over-engineered, and the sign of someone who's too excited about language features. The code can be solved without OOP, there's no actual (conditional) control flow, the kata doesn't focus on functions, and depending on your language, "method" and "function" are simply aliases.

    I propose the following tags instead:

    • bugs
    • syntax error
  • emporio Avatar

    Can someone help me improve the test case so that warriors cannot solve this by simply entering return "string".

  • DivyanshBatham Avatar

    This comment has been hidden.

  • Ulf Nordson Avatar

    IMHO - There's no decent description to this kata

  • MMMAAANNN Avatar

    Example Test Case is not formatted properly. It must have "string" as the second argument.

  • kolohelios Avatar

    I don't think this kata needs much more to be ready; it's kind of fun to see how many problems can be made in one place. Maybe a count of the total number of problems with the kata would be nice although working through it iteratively isn't the end of the world.

  • GiacomoSorbi Avatar

    Some example test code or some tip in the description about what the function expects may help, as I blindly tried a bit before going for the most obvious way, thinking there was some further trick to figure out.