RSPEC 2 -- substrings

so i have my solution as below, it will only work on “cat”, but not on “hello” because there will be one extra “l”. I cant figure out how to fix this, any insight would be helpful. Thanks!

def substrings(string)
i = 0
j = 0
result = []

while i < string.length
while j < string.length
result << string[i…j]
j += 1
end
i += 1
j = i
end
result
end

I just figured it out now, please disregard. Thanks! (sorry)

Glad you figured it out! Would you mind sharing what the problem with your code was and how you fixed it in case someone else runs into a similar problem?