Skip to content

Instantly share code, notes, and snippets.

@dance2die
Created March 11, 2018 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dance2die/30d8fa3f3c240c8cbafcf2c16ad2d161 to your computer and use it in GitHub Desktop.
Save dance2die/30d8fa3f3c240c8cbafcf2c16ad2d161 to your computer and use it in GitHub Desktop.
function reverseDemo(orders) {
const mid = orders.length / 2;
const leftHalf = orders.slice(0, mid);
const rightHalf = orders.slice(mid);
const combinedOrders = rightHalf.concat(leftHalf);
const indentBy = 4;
printHeaderFooter(
"Reversing from this list",
() => printOrders(combinedOrders, indentBy),
indentBy,
"*"
);
const reversedOrders = combinedOrders.reverse();
printOrders(reversedOrders);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment