Looping Triangle

Recent code challenge I came across. Complete in Ruby and JavaScript with room to refactor. This is my first solution.