From cfeb2ed971005aabca60102eb942ac7e1f9c819c Mon Sep 17 00:00:00 2001 From: Vamshi Krishna S Date: Fri, 6 Oct 2017 16:53:17 +0530 Subject: [PATCH] changed for loop to es6 standard --- index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 51d9b3a..4761d46 100644 --- a/index.js +++ b/index.js @@ -60,9 +60,10 @@ let variance = numbers => { return null; } let initialMean = mean(numbers); - let varianceNumbersArray = [], i; - for(i = 0; i < numbers.length; i += 1) { - let varianceNumber = numbers[i] - initialMean; + let varianceNumbersArray = []; + + for (let value of numbers) { + let varianceNumber = value - initialMean; varianceNumbersArray.push(varianceNumber * varianceNumber); } let variance = mean(varianceNumbersArray);