+ 1
necesito que me solucionen este codigo,soy nuevo en ruby y no se como podria para no tener que sustituir el numero impar por un
10 Respuestas
+ 2
I made your code a bit shorter, but I think it is still not what you want:
array = [2,4,5,8]
arrayP = []
array.each do |x|
arrayP = 0 # default
if x%2 == 0
arrayP = x
end
puts arrayP
end
+ 1
i want that the result is this:[2,4,8]:i think that eliminate the zero,the length of the array is one less and sorry,i am spanish therefore i prefered write in spanish
+ 1
yes,but alone the pair numbers of this array quit the odd numbers
+ 1
for example,you have this array:[1,2,4,6],the result array is this:[2,4,6]
0
the output that i want is this : [2,4,8]