Problem · String
Scale Ingredient Quantities
Learn this problemProblem statement
Each string in ingredients begins with an integer quantity followed by its unit and ingredient name. Multiply every quantity by people and preserve the rest of each string.
Function
scaleIngredients(ingredients: String[], people: int) → String[]Examples
Example 1
ingredients = ["100 g flour","50 g water","10 g sugar"]people = 8return = ["800 g flour","400 g water","80 g sugar"]Each leading quantity is multiplied by 8.