Created
August 7, 2017 12:52
-
-
Save Alevale/4b609517fe4a5be311c75e596259b154 to your computer and use it in GitHub Desktop.
SHIT CODE, PLEASE DON'T DO IT!! (I can explain you why)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an example of what you SHOULDN'T DO sadly, there is pple that will never learn how to program 😢