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.
My solution passes those. But fails one in the final run. (the first one)
Not an issue
"Boom, you failed to cut the wire"
This is more riddle than coding challenge, and apparently I am bad at riddles. Can someone give me a hint?
var wireCode = 1; // Find the wire.
var Bomb = {
CutTheWire: function(wireKey) {
if (wireKey = 1) {
return;
}
},
Explode: function() { return }
}
Bomb.CutTheWire(wireCode);
Here are the ones I wrote if they help:
const sqr = once((x) => { return x * x})
Test.assertEquals(sqr(3), 9)
Test.assertEquals(sqr(5), undefined)
const add = once((a,b) => { return a + b })
Test.assertEquals(add(1,2), 3)
Test.assertEquals(add(5,9), undefined)
Test.assertNotEquals(add(1,2), 3)
@osuushi yes, I realized my mistake a long time ago ;)
Your returned function doesn't return anything.
What does your resulting function return?
You're returning a function, but that function doesn't return anything.
Your solution only works if the function has one or zero arguments. The tests won't pass unless it can take any number of arguments.
Can someone provide an example of what a test looks like for this kata? Even just how to test the call in the kata description.
Here's my code:
function once(fn) {
var executed = false;
return function(variable) {
if (!executed) {
executed = true;
fn(variable);
}
}
}
Yep. Your function returns undefined and the tests pass it as the argument to your function again.
Using push on undefined causes the error.
I've passed the kata. Just trying to understand the guts of the call stack.
This is the line that causes the error:
addWord(addWord(list, 'how are you'), 'goodbye');
So I'm guessing that because the nested call to addWord hasn't returned 'goodbye' cannot be appended.
Why have you commented out the return statement? Your function should return the array after appending to it.
This comment is hidden because it contains spoiler information about the solution
Not so
Loading more items...