JS. Unable to output float with alert() : <p>(repost because my former post was unable to get bumped up for some reason)
I currently have a script that takes numbers from a text area and does all sorts of calculations with them. I am having trouble with my standard deviation function because it will not output the value even though it's type is number, and it is positive (.56).</p>

<p>When I run this code</p>

<pre><code>var variance = findVariance(array);
    variance = parseFloat(variance);
    alert(typeof variance);
</code></pre>

<p>the result is</p>

<blockquote>
  <p>number</p>
</blockquote>

<p>And the value is .56 (which I know because when I don't use parseFloat it returns .56 as a string). So I am baffled when I run this code</p>

<pre><code>alert("variance " + variance);
alert("sd" + Math.sqrt(variance));
</code></pre>

<p>and both alerts return</p>

<pre><code>NaN
</code></pre>

<p>This is the code that creates the textarea, calls the function processData( which gathers the input from myTextArea into an array and then calls the function findStandardDeviation) I can post the variance function as well if you'd like.</p>

<pre><code>&lt;textarea id="myTextArea" rows = "7" cols = "50"&gt;&lt;/textarea&gt;&lt;br&gt;

&lt;button onclick="processData()"&gt;Done&lt;/button&gt;

&lt;p id = "sd"&gt;&lt;/p&gt;

&lt;script type = "text/javascript"&gt;

    var standard_deviation = 0;

    var sdOutput = document.getElementById('sd'); 

function processData()
{
    var arrayOfLines = document.getElementById('myTextArea').value.split('\n');


    findStandardDeviation(arrayOfLines);
}
</code></pre>

<p>And here is the my reduced script:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;script type = "text/javascript"&gt;
		
		var mean = 0;
		var median = 0;
		var count = length;
		var mode = 0;
	
		var standard_deviation = 0;

		var meanOutput = document.getElementById('mean'); 
		var countOutput = document.getElementById('count'); 
		var sumOutput = document.getElementById('sum'); 
		var varianceOutput = document.getElementById('variance'); 
		var sdOutput = document.getElementById('sd'); 

	function processData()
	{
		var arrayOfLines = document.getElementById('myTextArea').value.split('\n');

		var sum = findSum(arrayOfLines);
		findMeanOutput(arrayOfLines, sum);
		findVariance(arrayOfLines);
		findStandardDeviation(arrayOfLines);
	}

	function findSum (array)
	{
		var count = array.length;
		var sum = 0;

		for (var a = 0; a &lt; array.length; a++)
		{
			sum += parseInt(array[a]);
		}
		
		countOutput.innerHTML = "Count: " + array.length; 
		sumOutput.innerHTML = "Sum: " + JSON.stringify(sum); 
		sum = parseInt(sum);
		return sum;
	}

	function findMean (array) //Used for finding mean and then returning it
	{
		var sum = 0;

		for(var a = 0; a &lt; array.length; a++)
		{
			sum += parseFloat(array[a]);
		}

		mean = sum/array.length;
		return mean; 
	}

	function findMeanOutput (array, sum) //finds mean and then establishes it as the mean for users input
	{
		mean = sum/array.length;
		meanOutput.innerHTML = "Mean: " +  mean; 
	}

	

	function findVariance (array) 
	{
		var mean = findMean(array);

		var variance = "Variance: " + findMean(array.map(function(num) 
		{
			return Math.pow(num - mean, 2);
		})).toFixed(2);

		varianceOutput.innerHTML = "Variance: " + variance;
		return variance;
	}

	function findStandardDeviation (array) 
	{
		var variance = findVariance(array);
		variance = parseFloat(variance);
		alert(typeof variance);
		alert("variance " + variance);
		alert("sd" + Math.sqrt(variance));
		sdOutput.innerHTML = "Standard Deviation: " + Math.sqrt(variance).toFixed(2); 
	}

&lt;/script&gt;</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
&lt;head&gt;

&lt;/head&gt;
&lt;body&gt;

&lt;p&gt; Please enter a series of numbers, each separated by a new line.&lt;br&gt;&lt;p&gt;

&lt;textarea id="myTextArea" rows = "7" cols = "50"&gt;&lt;/textarea&gt;&lt;br&gt;

&lt;button onclick="processData()"&gt;Done&lt;/button&gt;

&lt;p id = "mean"&gt;&lt;/p&gt;
&lt;p id = "count"&gt;&lt;/p&gt;
&lt;p id = "sum"&gt;&lt;/p&gt;
&lt;p id = "variance"&gt;&lt;/p&gt;
&lt;p id = "sd"&gt;&lt;/p&gt;



&lt;/body&gt;
&lt;/html&gt;</code></pre>
</div>
</div>
</p>
