Total newbie here and wouldn't mind learning from Rubyists to look at how I tried to solve this challenge.
I started with 2 variables n which starts at 0 and total which is an array where I intend to push n if it satisfy the condition set by the 2 modulo. Using the until loop with a max of 1000, my intention was to change total from an empty array with values divisible by 3 and 5.
With total now with array items, I defined a method to take in total as a parameter that I can iterate to add values to a new method variable - sum. The method then returns the new value of sum.
Here's my code.
n = 0
total = []
until n >=1000 do
if n % 3 == 0 || n % 5 == 0
total << n
end
n += 1
total
end
def sumTotal(total)
sum = 0
total.each { |i| sum+= i.to_i}
puts sum
end
sumTotal(total)