can anyone help me write code with (.each) nested loop.
in app academy it has been done with while loop.
i have tried all way but noyt getting result with .each method.
question:Write a method
array_translate that takes in an array whose elements alternate between words and numbers. The method should return a string where each word is repeated the number of times that immediately follows in the array.
here is my code, please correct me.
i = 0
array.each do |ele,num|
ele = array[i]
num = array[i + 1]
i += 2
print array_translate([“Cat”, 2, “Dog”, 3, “Mouse”, 1]); # => “CatCatDogDogDogMouse”
print array_translate([“red”, 3, “blue”, 1]); # => “redredredblue”