# Last intermediate algorithm help

Last intermediate algorithm help
0

#1

Can anyone figure out why the last case test on the last intermediate algorithm won’t work with this solution? I think it has something to do with the arguments.length being only 1 when it should be getting passed 2 arguments ?

``````
function addTogether(x, y) {               //outer function
arr = [];
for (i in arguments)  {
arr.push(arguments[i]);
}
if (!arr.every(numTest))  {
console.log("undefined")
return undefined;
} else if (arguments.length > 1) {
console.log(x + y);
return x + y;
}

var sumOfTwo =  function(y) {         //inner function
console.log(x + y);
return x + y;
}

console.dir(sumOfTwo);
return sumOfTwo;
}

function numTest(obj)  {
if (typeof obj === 'number') {
return true;
}
return false;
}

``````

#2

It looks like the parameter for Y is bypassing your outer functions numTest(). The innerFunction is grabbing it and returning the operation making it a string, not a number. The function concatenates 2 & 3 to make “23”

#3

I just figured out a different solution. I added a conditional to my inner function. I gotta try what you said and see which one I like more. Thanks man! Here’s what I did btw

``````function addTogether(x, y) {               //outer function

console.log(arguments);

arr = [];
for (i in arguments)  {
arr.push(arguments[i]);
}

if (!arr.every(numTest))  {
console.log("undefined")
return undefined;
} else if (arguments.length > 1) {
console.log(x + y);
return x + y;
}

var sumOfTwo =  function(y) {         //inner function
if (!numTest(y)) {
console.log(undefined);
return undefined;
}
console.log(x + y);
return x + y;
}

console.dir(sumOfTwo);
return sumOfTwo;
}

function numTest(obj)  {
if (typeof obj === 'number') {
return true;
}
return false;
}
``````

#4

Yeah that is what I was working on just now too. Good job!

#5

Thanks for your help man really encouraging to get feedback to quickly