Arguments Optional Solving Issues

Tell us what’s happening:
Describe your issue in detail here.

Hello Friends,
Hope you are having a happy coding time, I’m trying to solve this problem but something is going wrong any advice or link I should check ?

Thanks a lot !

Create a function that sums two arguments together. If only one argument is provided, then return a function that expects one argument and returns the sum.

If either argument isn’t a valid number, return undefined.

   **Your code so far**
function addTogether() {
let sum = 0;
if(typeof(arguments[0]) == "number" && typeof(arguments[1]) == "number"){
  sum = arguments[0]+arguments[1];

}else if(typeof(arguments[0] !== "number") || typeof(arguments[1]) !== "number"){
  sum = undefined;
   sum = (a) => {
    return (b) => {
      return a+b;

return sum; 

   **Your browser information:**

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36

Challenge: Arguments Optional

Link to the challenge:

This condition isn’t correct. If I pass only one argument to the function (the second one will be undefined) then instead of giving back another one function it will return undefined.

this one looks incorrect as well.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.