I made a simple code that adds the arrays, but how do I multiply them?
<h1>The % Operator</h1>
<p id="demo"></p>
<input type="submit" value="Multiplicacion DE VALORES MEDIANTE CICLOS, ARRAYS Y ACUMULADOR"onClick="ciclos();"/>
<script>
function ciclos() {
var arrayU = new Array(3);
var f;
for (f=0;f<arrayU.length;f++) { // ARRAY LENGTH = 3 = FOR = 0, 1 , 3
var v = prompt('Ingresa los 3 valores a multiplicar:','');
arrayU[f] = parseInt(v);
}
var total = 0;
//var multiplicacion;
//var number;
for (f=0;f<arrayU.length;f++) {
total = arrayU[f] + total;
}
document.write(total);
}
</script>
</body>
</html>
I know it can be done like that, but it's very manual:
function arrayManual() {
var arrayU = new Array(3);
arrayU[0] = prompt('Ingresa el 1er numero:','');
arrayU[1] = prompt('Ingresa el 2do numero:','');
arrayU[2] = prompt('Ingresa el 3er numero:','');
document.write(arrayU[0] * arrayU[1] * arrayU[2]);
}