JSFiddle - React, Tailwind, and code Playground

by chrisloughnane

JavaScript

const numbers = [-5, 6, 2, 0,10,3,1];

const doubledPositiveNumbers = numbers.reduce((previousValue, currentValue) => {
  if (currentValue > 0) {
    previousValue.push(currentValue * 2.3);
  }
  return previousValue;
}, []);

console.log(doubledPositiveNumbers); // [12, 4]