Why using arguments[i] in the code below gives error?

not error

error

Just to try - substitute args for arguments

@rickstewart args will be the first argument ie [1,2,3]. I used a counter ‘i’ here to make my program general enough to handle more than 2 args. The program needs some correction to make it general enough to find symettric differnce of more that 2 arguments but first I have to solve this problem.

You’re right - sorry about that - I didn’t look close enough or long enough…

@rickstewart no need to say sorry.

This is the way I usually make logic, am I doing wrong or is it fine?


@daemus this is the solution that I opted.

why do I get “dont make functions within loop” warnings when I havent made any functions within loop?

You’re getting that error on the second invocation of the filter callback. At that point, i+1 would be 2, resolving to arguments[2].indexOf(a). That element doesn’t exist, meaning that indexOf doesn’t exist.

@daemus loop will run for i = 0 only then how come i will be 2 ?
In the for loop, condition is i < arguments.length - 1 // i < 1

I stand corrected. I did not notice that in the conditional.

You’ll want to save the original function’s arguments object into another variable, then access that within the filter callback.