Switch Case

Run Settings
LanguageJavaScript
Language Version
Run Command
const basketballScored = [{name:"john",score:[200,120,104]},{name:"mike",score:[200,120,104]},{name:"mary",score:[200,120,104]}]; function countAverage(name){ const getProfile = basketballScored.find(x => x.name === name); const sumAll = getProfile.score.reduce(reduceNumber); return sumAll/getProfile.score.length; } function reduceNumber(total, num){ return total + num; } const averageJohn = countAverage("john"); const averageMike = countAverage("mike"); const averageMary = countAverage("mary"); console.log("John : "+averageJohn); console.log("Mike : "+averageMike); console.log("Mary : "+averageMary); if(averageJohn > averageMike && averageJohn > averageMary){ console.log(`John Win with average score ${averageJohn}`) }else if(averageMike > averageJohn && averageMike > averageMary){ console.log(`Mike Win with average score ${averageMike}`) }else if(averageMary > averageJohn && averageMary > averageMike){ console.log(`Mary Win with average score ${averageMary}`) }else if(averageMike === averageJohn && averageMike === averageMary && averageJohn === averageMary){ console.log(`THEY HAVE A SAME AVERAGE SCORE`) } else if(averageMike === averageJohn){ console.log(`John and Mike A SAME AVERAGE SCORE`) }else if(averageJohn === averageMary){ console.log(`John and Mary A SAME AVERAGE SCORE`) }else{ console.log(`Mike and Mary A SAME AVERAGE SCORE`) }
Editor Settings
Theme
Key bindings
Full width
Lines