7 kyu

Javascript Namespacing

2,218 of 2,288arlaneenalra
Description
Loading description...
Object-oriented Programming
Fundamentals
  • Please sign in or sign up to leave a comment.
  • farhanaditya Avatar

    Creating class like that feels kinda wierd tbh.

  • JoshSchreuder Avatar

    Hi, I've added a CoffeeScript translation, if you want to approve it, instructions for the approval process are here.

  • emporio Avatar

    You say in the assignment: "It should also have a function named sayHello that returns the string passed into the constructor." You should be more specific with what you mean by "It". Please try to rephrase the sentence.

  • computerguy103 Avatar

    There is actually no such thing as a "namespace" in Javascript. Therefore, the description needs to explain how to create something that acts like a namespace in Javascript, or it needs to at least provide a link to additional information.

    You shouldn't just expect us to have to Google it and figure it out.

  • paragonHex Avatar

    If that namespace weren't pre-defined, I wouldn't had to google for, and learn about them at all. So, I guess... Thanks for introducing me namespaces!

  • abruzzi Avatar

    Hey bro, the existing 'MyNamespace' really hit me...

  • dcorking Avatar

    This comment has been hidden.

  • user3482173 Avatar

    You should provide some reference about namespace for a beginner kata.

  • ABNW Avatar

    This comment has been hidden.

  • UXrOy1uvaJY8NWxkIH1x Avatar

    The example in the description says "var phrase = myObject.sayHello(); // phrase should be 'Hello!'".

    Because of the naming I believed that the sayHello function should always output "Hello!" and was wondering why it was specified that the constructor must accept a string. This lead to my solution failing because the test cases were looking for just "hello".

    Am I now correct in understanding that sayHello should return the string passed to the constructor and not "hello"?

  • james0r Avatar

    Whatever it's worth, reading the instructions, I didn't realize that the namespace already existed. I had to read through all the discussion posts to figure it out.

  • slocodemonkey Avatar

    Yep. The existing 'MyNamespace' nailed me too. Probably should explicitly say in the description that the namespace already existed.

    That being said, I really hadn't messed with JavaScript namespaces at all prior to this kata, so... OS!!!!

  • ppaul Avatar

    javascript doesn't support classes! So the requirement is a little misleading...

  • david_posin Avatar

    I made the same mistake for the longest time: MyNameSpace vs. MyNamespace.....I wonder if the MyNameSpace could be changed to something less likely to cause confusion. Although, I understand that the MyNamespace is the correct capitalization since Name and Space aren't separate words.

  • pentaphobe Avatar

    This comment has been hidden.

  • GuardianGI Avatar

    it would have helped A LOT if the description dais the namespace is already defined and should not be overwritten entirely....

  • adriaanbaelus Avatar

    Another small improvement could be to use more meaningful names, for example:
    Define a class named Doorman inside a namespace MyHotel. The class constructor should accept a single greeting string argument. It should also have a function named sayHello that returns the greeting passed into the constructor.

  • jhoffner Avatar

    The final test case was stumping me because the description doesn't say anything MyNamespace already being defined.

    Also this:

    The class constructor should accept a single, string argument and a function named sayHello the string

    would read better as this:

    The class constructor should accept a single string argument. It should have a function named sayHello that returns the string passed into the constructor.