-
-
Save AliceWonderland/adabfc02b657e69f38d1a0d6e298f946 to your computer and use it in GitHub Desktop.
6.3 Median of Mean created by smillaraaq - https://repl.it/HGEl/5
This file contains hidden or 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
function mean(score1, score2, score3){ | |
var totalScore=0; | |
totalScore+=score1; | |
totalScore+=score2; | |
totalScore+=score3; | |
var totalMean=totalScore/3; | |
return totalMean; | |
} | |
function median(mean1, mean2, mean3){ | |
//arrange ascending then look for middle | |
console.log(mean1, mean2, mean3); | |
var theMedian; | |
if(mean1>mean2){ | |
if(mean1>mean3){ | |
if(mean2>mean3){ | |
theMedian= mean2; | |
}else{ | |
theMedian= mean3; | |
} | |
} | |
}else{ | |
theMedian= mean1; | |
} | |
return theMedian; | |
} | |
var myClass = [[93, 73, 98], [54, 87, 63], [99, 45, 78]]; | |
//mean(myClass); | |
median( | |
mean(myClass[0][0], myClass[0][1], myClass[0][2]), | |
mean(myClass[1][0], myClass[1][1], myClass[1][2]), | |
mean(myClass[2][0], myClass[2][1], myClass[2][2]) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment