function captureArguments(arg1, arg2, arg3) {
if (
//first section
(arg1 === null && arg2 === null && arg3 === null) ||
arguments.length === 0
) {
return "Nothing Passed";
} else if (
typeof arg1 === typeof arg2 &&
typeof arg2 === typeof arg3
) {
return "All the same";
}
//second section
if (arg1 !== null && arg2 === null && arg3 === null) {
return alpha;
}
if (arg1 === null && arg2 !== null && arg3 === null) {
return second;
}
if (arg1 === null && arg2 === null && arg3 !== null) {
return gamma;
}
//third section
if (arg1 === "string" && arg2 === "string" && garg3 === "string") {
return {
first: arg1,
second: arg2,
third: arg3
}
}
My goal is to 1. check if an argument is being passed, 2. if ex captureArguments("first", null, null) then it return the value "first", 3. if all parameters are of string value for it to return it ex. captureArguments("ball", "hill", "water") returns {first: "ball", second "hill, third:"water}. Third section keeps returning undefined
2
Answers
It is not 100% clear what you want, but this code should contain all possible tests you need