Skip to content

Instantly share code, notes, and snippets.

@basicssm
Created February 18, 2019 10:04
Show Gist options
  • Save basicssm/7cf43bceaf0d16517e2b6b02dc9ae014 to your computer and use it in GitHub Desktop.
Save basicssm/7cf43bceaf0d16517e2b6b02dc9ae014 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/cujiweq
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
"use strict";
var movements = [11.22, 3.12, 5.8, 3, 100.2];
var boost = 2;
function roundCalc(movements) {
return movements.reduce(function (acc, movement) {
return acc + (Math.ceil(movement) - movement);
}, 0);
}
console.log(roundCalc(movements) * boost);
</script>
<script id="jsbin-source-javascript" type="text/javascript">const movements = [11.22, 3.12, 5.8, 3, 100.2];
const boost = 2;
function roundCalc(movements){
return movements.reduce((acc, movement) => acc + (Math.ceil(movement) - movement), 0);
}
console.log(roundCalc(movements) * boost);</script></body>
</html>
"use strict";
var movements = [11.22, 3.12, 5.8, 3, 100.2];
var boost = 2;
function roundCalc(movements) {
return movements.reduce(function (acc, movement) {
return acc + (Math.ceil(movement) - movement);
}, 0);
}
console.log(roundCalc(movements) * boost);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment