May 10th Codewar

·

1 min read

I was alone at the desk at work today, so I took that time to do Codewars!

*Problem: There was a test in your class and you passed it. Congratulations! But you're an ambitious person. You want to know if you're better than the average student in your class. You receive an array with your peers' test scores. Now calculate the average and compare your score! Return True if you're better, else False!*

* Pseudo Code: / First asking to find average of the class points array -iterate through the array with a loop find the average Asking for a conditional compare both parameters */

Solution:

function betterThanAverage(classPoints, yourPoints) {
  // Your code here
let total = 0;
for(let i = 0; i < classPoints.length; i++) {
    total += classPoints[i];
}
 let avg = total / classPoints.length;
console.log(avg)
  if (yourPoints > avg){
    return "true";
  }else{
    return "false";
  } 
}

I did not pass it, for a very small very annoying reason. They asked to return a boolean not a string. Needless to say I will NEVER forget this again. I am still very proud to have gotten very close! Now to push it to GitHub!