Why isn't Math.round converting it to 2 decimals?


#1

//input numbers here
var medi1 = 23; 
var medi2 = 81;
var medi3 = 78;
var medi4 = 849;
var medi5 = 78;
var medi6 = 65;
var medi7 = 543;
var medi8 = 78;
var medi9 = 55;
var medi10 = 1;
// 10 Variables
var findMedi = function(a, b, c, d, e, f, g, h, i, j) {
    
var add = a + b + c + d + e + f + g + h + i + j;    
//Divide by how many variables
var div = add / 10;
console.log("The Mean is " + div);
};

var add = medi1 + medi2 + medi3 + medi4 + medi5 + medi6 + medi7 + medi8 + medi9 + medi10;    
var div = add / 10;
var find1 = medi1 - div;
var find2 = medi2 - div;
var find3 = medi3 - div;
var find4 = medi4 - div;
var find5 = medi5 - div;
var find6 = medi6 - div;
var find7 = medi7 - div;
var find8 = medi8 - div;
var find9 = medi9 - div;
var find10 = medi10 - div;

var convert1 = Math.abs(find1);
var convert2 = Math.abs(find2);
var convert3 = Math.abs(find3);
var convert4 = Math.abs(find4);
var convert5 = Math.abs(find5);
var convert6 = Math.abs(find6);
var convert7 = Math.abs(find7);
var convert8 = Math.abs(find8);
var convert9 = Math.abs(find9);
var convert10 = Math.abs(find10);

var round1 = Math.round(convert1 * 10)/10;
var round2 = Math.round(convert2 * 10)/10;
var round3 = Math.round(convert3 * 10)/10;
var round4 = Math.round(convert4 * 10)/10;
var round5 = Math.round(convert5 * 10)/10;
var round6 = Math.round(convert6 * 10)/10;
var round7 = Math.round(convert7 * 10)/10;
var round8 = Math.round(convert8 * 10)/10;
var round9 = Math.round(convert9 * 10)/10;
var round10 = Math.round(convert10 * 10)/10;
//again 10 variables
var add1 = (round1 + round2 + round3 + round4 + round5 + round6 + round7 + round8 + round9 + round10);
var div1 = add1 / 10;
findMedi(medi1, medi2, medi3, medi4, medi5, medi6, medi7, medi8, medi9, medi10);
console.log("The Absolute Mean Deviation is " + div1);

#2

#3

What exactly are you trying to say?


#4

That you can use Number.toFixed(n) to get a number round to n decimals. What is your question?


#5

Math.round isn't rounding the variable to the nearest 3 decimal points and I don't know why.


#6

Why should it?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round