Tell us what’s happening:
I got stuck in this problem so I peeked at the solution and almost wrote the same approach as the first solution, however for some reason it only works when I call the function twice while switching the parameters location in the function call. I would love if someone can explain to me why is this not working.
It only works when I call the function twice in a row for somereason, would love some explanation to why it did not work
I’m having a hard time understanding what you are asking here. I think you are asking, “Why do I need to call newTry twice (with switched parameters) and it won’t work if I call it only once?”
If that is your question, then it is because newTry checks if there are any elements in the first array that are not in the second. If you only did it with arr1 as the first array, it would only push on elements that arr1 has that arr2 doesn’t. But of course you could also have elements in arr2 that arr1 doesn’t have. Or both or neither of those could be true.
If that isn’t the question you are asking, please be more specific, with code examples and fewer pronouns.