I have completed writing this function and tested it to ensure that it works with the data you provided. Please message me directly before accepting the bid.
------
I work with JavaScript and JSON objects regularly for various websites that I have made and maintain.
This would take a short period of time (Estimated for about an hour), and full source & documentation will be provided if requested.
While waiting for your reply to my proposal, I'll begin working on this.