I managed to solve this algorithm challenge but I don’t understand how this code works?
If someone could break it down for me to understand, it would be much appreciated
You wrote it, so why don’t you walk us through what you were trying to do and how you expected it to behave, and we can help fill in the holes?
I wanted to use the arguments method to find the arguments outside of the array.
Then I used the filter method to create a new array if ‘begone’ can be found in ‘num’, and I think I wanted to return the array if the argument was true.
What I don’t understand is why the empty return statement allows the code to run?
The line below:
returns undefined as a value. It is if would have been written:
Whether or not you put that 2nd return statement or not is irrelevant, because the first return
is actually going to return the final value. The single return; will never execute.
Ok, thank you, I understand it better now.