Snippets Collections
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)
 }
function positiveSum(arr) {
  var total = 0;    
  for (i = 0; i < arr.length; i++) {   
    if (arr[i] > 0) {                   // if arr[i] es mayor a 0
      total += arr[i];                  // dar el total de la suma de esos arr[i]
    }
  }
  return total;                         // return total
}
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 14:49:00 GMT+0000 (Coordinated Universal Time) https://www.codewars.com/kata/5715eaedb436cf5606000381/solutions/javascript

#javascript #array #operaciónmate #for

Save snippets that work with our extensions

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