Skip to content

Commit e60007b

Browse files
authored
feat: Added Standard Deviation algorithm for Math
1 parent 1f13f09 commit e60007b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Maths/StandardDeviation.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Returns the standard deviation given an array of integers
3-
* @param int[] nums array of integers
4-
* @return int standard deviation
3+
* @param number[] nums array of integers
4+
* @return number standard deviation
55
* @see https://en.wikipedia.org/wiki/Standard_deviation
66
*/
77
function standardDeviation(nums) {
@@ -14,8 +14,8 @@ function standardDeviation(nums) {
1414

1515
let sum = 0
1616
for (let i = 0; i < nums.length; i++) {
17-
if (!Number.isInteger(nums[i])) {
18-
throw new TypeError('Integer type required in array input!')
17+
if (isNaN(nums[i])) {
18+
throw new TypeError('Number type required in array input!')
1919
}
2020
sum += nums[i]
2121
}

0 commit comments

Comments
 (0)