I am really new to Ruby programming and am in the process of trying to learn it. one of the “assignments” I was given is really stumping me.
I need to make a table with 2 columns. the first column will have a list of numbers 1 through 100,
the second column will print out the results as per my code.
My ruby code looks like this:
(1..100).each do |i|
d3 = (i % 3 == 0)
d5 = (i % 5 == 0)
i = "_#{i}_" if d5
i = "*#{i}*" if d3
puts i if d5 || d3
end
How would I put this in an HTML table?
I’m not sure if your using rails or not, but you’ll need to make sure it using erb this might help. But something like this should do the trick: