7 kyu

Javascript Namespacing

2,232 of 2,302arlaneenalra

Description:

Define a class named MyClass inside a namespace MyNamespace. The class constructor should accept a single string argument. It should also have a function named sayHello that returns the string passed into the constructor.

Example:

var myObject = new MyNamespace.MyClass('Hello!');

var phrase = myObject.sayHello(); // phrase should be 'Hello!'

The interesting part is that MyClass should only be accessible via the namespace and should not define any extra global variables. Code should not redefine an existing namespace, but should also function if the namespace is not previously defined.

Object-oriented Programming
Fundamentals

More By Author:

Check out these other kata created by arlaneenalra

Stats:

CreatedOct 2, 2013
PublishedOct 2, 2013
Warriors Trained5364
Total Skips1329
Total Code Submissions23017
Total Times Completed2302
JavaScript Completions2232
Total Stars74
% of votes with a positive feedback rating75% of 162
Total "Very Satisfied" Votes105
Total "Somewhat Satisfied" Votes34
Total "Not Satisfied" Votes23
Ad
Contributors
  • arlaneenalra Avatar
  • jhoffner Avatar
  • booniepepper Avatar
Ad