Created
August 17, 2014 01:44
-
-
Save chimanaco/2645e64e517f79d0acef to your computer and use it in GitHub Desktop.
Display number from array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title>Calculate decimal places</title> | |
</head> | |
<body style=""> | |
<script> | |
var array = [ | |
295.425, | |
286.958, | |
278.491, | |
270.025, | |
261.558, | |
253.091, | |
244.625, | |
236.827, | |
229.048, | |
221.302, | |
213.607, | |
205.978, | |
198.431, | |
190.981, | |
183.644, | |
176.435, | |
169.369, | |
161.064, | |
152.402, | |
143.504, | |
135.258, | |
127.012, | |
118.766, | |
110.520, | |
102.274, | |
94.029, | |
85.783, | |
77.537, | |
69.291, | |
61.045, | |
52.799, | |
44.554, | |
36.308, | |
28.062, | |
19.816, | |
11.570, | |
3.325 | |
]; | |
// length | |
console.log(array.length); | |
for(var i = 0; i< array.length; i++) { | |
var _val = array[i] - 3.325 - 146.05; | |
// decimal places * 10 | |
// three decimal places 10 * 10 * 10 | |
var val = Math.floor(_val * 1000) / 1000; | |
// display number | |
console.log(val); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment