It can be quite complicated to understand what needs to be done. There are always many ways to do something when coding but regardless of the algorithm used, we have to create a program that does the following:
* It has to add two numbers passed as parameters and return the sum.
* It has to check if any of the numbers are actual numbers, otherwise return **undefined** and stop the program right there.
* It has to check if it has one or two arguments passed. More are ignored.
* If it has only one argument then it has to return a function that uses that number and expects another one, to then add it.
Every time you deal with an argument, you have to check if it is a number or not. For this a function that handles this task will save you repeated code.
When working on the case that it needs to return the function, it is wise to check if the first and only argument is a number again and base the code on that.
In the case that only one argument was passed, do not worry about how to prompt input for the second one, just make the function definition properly and things will work out the way they should.
* First, I create a function with the sole purpose of checking if a number is actually a number and returns undefined if it is not. It uses **typeof** to check.
* Check if we have two parameters, if so, then check if they are numbers or not using the **checkNum** function I created.
* If they are not **undefined** then add them and return the addition. If they any of them is undefined then return undefined.
* In the case that we only have one argument, then we return a new function that expects two parameters. For this we store the first argument before going into a new scope to avoid our arguments being overwritten.
* Still inside the big else, we need to check the argument we saved, if it is a number then we return the function expecting a second argument.
* Now inside the function we are returning, we have to check for non numbers again just as at the beginning using **checkNum** if undefined then return that, otherwise if numbers add them and return the addition.