Numerical array

Hi,

Can anyone help me convert the inputs to numbers instead of strings?
I’m trying to make a calculator of sorts:crazy:

var array = new Array();

        function insert(val)
		{
            array[array.length]=val;
        }

        function show() 
		{
            var string="";
            for(i = 0; i < array.length; i++) 
		
            document.getElementById("e").value =    string=string+array[i]+"\

";

		}

One of the effective ways is to pass the value through the Number object. If it’s not a valid number, it will return NaN (not a number).
Since NaN is a falsy value, you can use the OR operator to provide a default value of 0 if no valid number can be made.


var string = field.value;
var number = Number(string) || 0.