diegodfsd
6/16/2017 - 5:05 PM

gistfile1.txt

let items = [4, 5, 80];
let results = [];

items.forEach(function(x) {
	let number = x;
  let result = 0;
  let a = 0;
  let b = 0;
  
  result = (number / 4);
  a = Math.round(result);
  b = result > 1? Math.round(result % 4) : 0;
  
  results.push( ((2*a) + b) );
});

console.log(results);