The Best of Deals

Avo, is it me you’re looking for?

Use JavaScript to: parse strings and convert them to numbers; loop through an array; compare the result of calculations.

We want to find the best place to buy some avocados. We like avocados because they are green. The supermarket has a set of different, slightly odd, offers for avos. A friend of ours has been hanging, staring at them, and has sent us this message:

"1 for R3, 2 for R7, 3 for R10, 5 for R14.50."

Use this string as your starting point. Use TDD and write functions that:

Your code should also work for this string or any other similar string:

"1 for R4, 2 for R6.54, 3 for R11, 5 for R15.75"