looping_arrays_5.rb
def total (prices)
  amount = 0 #start at 0
  index = 0 #start at first array of index
  while index < prices.length #while we're still within the array
    amount += prices[index] #add the current price to the total
    index += 1 #move to the next price
  end
  amount #return the total
end
#Given an array of prices, add them all together & return the value
Given an array of prices, add them all together & return the value
Given an array of prices add them all together & return the value
def total (prices)
  amount = 0 
  index = 0 
  while index < prices.length 
    amount += prices[index] 
    index += 1 
  end
  amount 
end
def total ( prices ) amount = 0 index = 0 while index < prices . length amount += prices [ index ] index += 1 end amount end
Given an array of prices, add them all together & return the value
Given an array of prices add them all together & return the value
#start at 0 #start at first array of index #while we're still within the array #add the current price to the total #move to the next price #return the total
prices