I'm trying to write a code which calculate the total of an array length of 3. Each 3 integers are from prompt.
Right now my code is like the following:
var num1 = prompt("First number");
var num2 = prompt("Second number");
var num3 = prompt("Third number");
var new_array = [num1, num2, num3]
function sum_three(new_array)
{
return new_array[0] + new_array[1] + new_array[2];
}
document.write(sum_three(new_array));
However when I see the result it seems that this
return new_array[0] + new_array[1] + new_array[2];
part does not calculate, it just concatenate the numbers. How do I make work?