Question:
Define a repeatify function on
the String object. The function accepts an integer that specifies how
many times the string has to be repeated. The function returns the string
repeated the number of times specified. For example:
Should print hellohellohello.
Answer
The question tests the knowledge
of the developer about inheritance in JavaScript and
the prototype property. It also verifies that the developer is able
to extend native data type functionalities (although this should not be done).
Another important point here is to demonstrate that you are aware about how to not override possible already defined functions. This is done by testing that the function didn’t exist before defining your own.
Another important point here is to demonstrate that you are aware about how to not override possible already defined functions. This is done by testing that the function didn’t exist before defining your own.
No comments:
Post a Comment