Skip to content
Snippets Groups Projects
Commit 6c8402d4 authored by Sebastian Pape's avatar Sebastian Pape
Browse files

Fixed error in statistics function, added statistics button and added resources (image of device)

parent 9be72337
No related branches found
No related tags found
No related merge requests found
......@@ -106,14 +106,18 @@
}
function calcStatistics(){
var array = document.getElementById("results").value.split(",");
if(array.length == 0) return;
var array = document.getElementById("results").value.split(",").map(function(num) {
return parseInt(num);
}).filter(function(num) {return !isNaN(num);});
if(array.length < 2){
document.getElementById("statistics").innerHTML = "";
} else {
document.getElementById("statistics").innerHTML = ""
+ "Mean: " + mean(array) + "<br />"
+ "Mean: " + mean(array).toFixed(2) + "<br />"
+ "Median: " + median(array) + "<br />"
+ "Variance: " + variance(array) + "<br />"
+ "StandardDeviation: " + standardDeviation(array);
+ "Variance: " + variance(array).toFixed(2) + "<br />"
+ "StandardDeviation: " + standardDeviation(array).toFixed(2);
}
}
document.onload = function(){
......@@ -155,6 +159,7 @@
<div class="button" style="background-color: #dc3545;" onclick="makeRequest('abort')">Abort!</div>
</div>
<div class="box niceBorder"><div class="button" onclick="getResults()">Get Results!</div></div>
<div class="box niceBorder"><div class="button" onclick="calcStatistics()">Statistics!</div></div>
</div>
</body>
</html>
\ No newline at end of file
resources/IMG_20191112_113410.jpg

215 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment