I have an array of strings from which I need to extract the first words, convert them to integers and get the their sum.
Example:
["5 Apple", "5 Orange", "15 Grapes"]
Run Code Online (Sandbox Code Playgroud)
Expected output => 25
My attempt:
["5","5","15"].map(&:to_i).sum
Run Code Online (Sandbox Code Playgroud)