var product2 = function product2(nums) {
var result = 1;
for (var i = 0; i < nums.length; i++) {
result *= nums[i];
}
return result;
};
var product = function product () {
var result = 1;
// the arguments object contains all arguments passed
// to the function
// it has a length property and it elements
// can be accessed with []
for (var i = 0; i < arguments.length; i++) {
result *= arguments[i];
}
return result;
};
Last active
October 5, 2015 19:19
-
-
Save gaand/3148d7ab2478d7c23254 to your computer and use it in GitHub Desktop.
product, two version
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment