I am attempting the following coding challenge.
Write a program to loop through the array named food and remove the end element of that array, and append it to the array named drink. The initial values of these arrays are:
food = ["Tempura", "Prawn", "Squid", "Fish", "Chips"]
drink = ["Kombucha", "Coconut Mango", "Allberry", "Yogurt Rice", "Milk bubble tea"]
I know how to get the last element from the first array and append it to the second array.
print drink << food.slice(-1)
I struggle with finding the loop so that I can get the following out.
food_&_drink = ["Kombucha", "Coconut Mango", "Allberry", "Yogurt Rice", "Milk bubble tea", "Chips", "Fish", "Squid", "Prawn", "Tempura"]
How to match element 1 from the food array to element 4 in the drink array. With the method that I know, I am not getting the output the want:
print food.flatten.zip(drink)