Ruby Array odd number issue

We are written below code, not sure where we went wrong-

def find_odd(first, last)
    #Write your code here and return the result
    result=[]
    last.step first, -2 do |x|
        result.push "#{x}"
    end
    return result
end

That depends on what you are trying to do?

Incidentally, why are you converting x to a string before adding it to the result array?

issue resolved

(first…last).select { |x| x % 2 == 1 }

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs