Skip to content

Instantly share code, notes, and snippets.

@diegodfsd
Created June 16, 2017 17:05
Show Gist options
  • Save diegodfsd/e489a4e74876d25c385598f81b86ad2c to your computer and use it in GitHub Desktop.
Save diegodfsd/e489a4e74876d25c385598f81b86ad2c to your computer and use it in GitHub Desktop.
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment