I am having a issue using the arguments object.
I am working on the Arguments Optional challenge and am trying to access the length of my arguments input.
const addTogether = (x, y) => {
console.log(arguments)
if (arguments.length == 1) {
return typeof x != "string" ? y => x + y : undefined
}
if (arguments.length == 2) {
return typeof y != 'string' ? x + y : undefined;
}
}
addTogether(2, 3);
When I try to console.log()
my arguments I get the following:
{ '0':
{ tryEntries: [ [Object], [Object], [Object] ],
prev: 10,
next: 0,
_sent: undefined,
sent: undefined,
done: false,
delegate: null,
method: 'next',
arg: undefined } }
No matter what I do I always get this same object. I tried arguments[0]
, arguments.length
(always returns 1) and [...arguments]
and I still cannot get a list of all the values.
Any ideas to what could be causing this?
Edit: My goal is to create a array with the parameters [x, y]
;
I also just noticed my code won’t work as intended if one of the values is a a array ([x]
or [y]
as per the tests). Will adjust when I get their.