Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Aren't unspecified parameters default to
undefined
?wow
Thanks! I understand now. My confusion was a result of me misreading the instructions. I can see that once is indeed only called once; I thought "logOnce" was the name of the "once" function; so I thought it was being called multiple times in the example given in the instructions.
Please google "closure" and you should be more clear on what he have done here. This "once" function is returning another function. The call variable is set to true the first time in "once" and it will not be set back to true again since we are calling the returned function not the "once" function in the main program.
I guess I don't understand this Kata, but wouldn't this function always run the given argument function? You're setting call to true everytime, so in what case would it be false in the anonymous function that is being returned? I can see its being set to false in the anon function, but once that function runs and you call once again, you run through the beginning again which sets call to true, and would make the function run again, wouldnt it?
Thakns.
When submitting, the error message returned would say "MyObject is undefined". I started out with this code:
var myObj = {};
myObj.proto = MyObject.prototype;
This threw me off; I thought MyObject was already defined, but the error messages along with that not being explicitly laid out in the description of this problem made me uncertain about this. Eventually I just wanted to look at the answer. I get the intention of the problem now, but it should be made clearer in its description.
var j was for debbugging purposes. I forgot to remove it.
What is wrong with those implementations, if I may ask?
I might be incorrect, but I believe these 2 are the same thing?