Skip to content

Instantly share code, notes, and snippets.

@Alevale
Created August 7, 2017 12:52
Show Gist options
  • Save Alevale/4b609517fe4a5be311c75e596259b154 to your computer and use it in GitHub Desktop.
Save Alevale/4b609517fe4a5be311c75e596259b154 to your computer and use it in GitHub Desktop.
SHIT CODE, PLEASE DON'T DO IT!! (I can explain you why)
// NOTE: THIS IS NOT MY CODE, it's just a cry because of the crap I see around... 20170807:Alevale
const allQuickReplies = [];
let newResult;
// TODO: sort / merge reply blocks
newResult = result.reduce((arr, res) => {
if (res.hasOwnProperty('quick_replies')) {
Array.prototype.push.apply(allQuickReplies, res.quick_replies);
} else {
arr.push(res);
}
return arr;
}, []);
if (allQuickReplies.length > 0) {
newResult[newResult.length-1].quick_replies = allQuickReplies;
}
return newResult;
@Alevale
Copy link
Author

Alevale commented Aug 7, 2017

This is an example of what you SHOULDN'T DO sadly, there is pple that will never learn how to program 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment