Grocery Store Prices

Published by Helen Yu in

You are given an array of strings consisting of grocery items, with prices in parentheses. Return an array of prices in float format.

Examples

getPrices(["ice cream ($5.99)", "banana ($0.20)", "sandwich ($8.50)", "soup ($1.99)"]) ➞ [5.99, 0.2, 8.50, 1.99]

getPrices(["salad ($4.99)"]) ➞ [4.99]

Notes

See if you can use RegExp to solve (but it's not necessary).

Watch a quick demo on how Edabit works.