0
There are two exercises that I need to solve using a cycle (or loop) FOR... In one of them, I need to catch one array
x as a parameter in a function, and multiply all its elements among themselves and return me the result. the other exercise is to write a function in which a number x, as parameter, is computed its factorial (i.e., the multiplication of itself by integers preceding it)...
the code I wrote for the array exercise:
function produto (pr) {
var total = 1;
for (var i = 0; i < pr.lenght; i++) {
total = total * pr[i];
}
return total
}
that of factoring:
function fatorial (x) {
var fat = 1
for (var i = 0; i <= x; i++){
fat = fat * x * i;
}
return fat;
}
neither of the two work. How can I solve them ?