Snippets Collections
function betterThanAverage(classPoints, yourPoints) {
  return yourPoints > classPoints.reduce((a, b) => a + b, 0) / classPoints.length; 
}
const points=games=>games.reduce((output,current)=>{
    return output += current[0]>current[2] ? 3 : current[0]===current[2] ? 1 : 0;
  },0)

//DIFERENTE ESCRITO:
 function points(games) {
   return games.reduce((output,current)=>{
     let x = parseInt(current[0]);
     let y = parseInt(current[2]);
     let value= x>y ? 3 : x===y ? 1 : 0;
     return output+value;
   },0)
 }
//Opción 1:
function findAverage(array) {
  if(array.length === 0) {
    return(0);
  }
  return array.reduce((a, b) => a + b, 0) / array.length;
} 

//Opción 2:
var find_average = (array) => {  
  return array.length === 0 ? 0 : array.reduce((a, b)=> a + b, 0)/array.length
}
star

Sat May 20 2023 18:13:21 GMT+0000 (Coordinated Universal Time) https://www.codewars.com/kata/5601409514fc93442500010b/solutions/javascript

#javascript #.reduce() #boolean
star

Sat May 20 2023 15:06:17 GMT+0000 (Coordinated Universal Time) https://www.codewars.com/kata/5bb904724c47249b10000131/solutions/javascript

#javascript #operaciónmate #array #.reduce() #parseint()
star

Sat May 20 2023 13:37:32 GMT+0000 (Coordinated Universal Time) https://www.codewars.com/users/MeridaK/completed_solutions

#javascript #array #.reduce() #if #.length

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension