Skip to content

Instantly share code, notes, and snippets.

@BolajiAyodeji
Created March 3, 2019 15:33
Show Gist options
  • Save BolajiAyodeji/71fa5e08d7b2d90a8b6f428e23147633 to your computer and use it in GitHub Desktop.
Save BolajiAyodeji/71fa5e08d7b2d90a8b6f428e23147633 to your computer and use it in GitHub Desktop.
The rest operator
function sum(discount, ...prices) {
const total = prices.reduce((a, b) => a + b);
return total * (1 - discount);
}
console.log(sum(0.1, 20, 30, 1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment