Helpppp please.my head hurt and i m about to beat this sit up

data=[0,1,2,-1,-3,-4,-6,-3]
newarray =[]

sum = 0
i = 0

while i < data.length
val1 = data[i]
j = i+1
while j < data.length
val2 = data[j]
sum = val2 + val1

newarray << val2 if sum == 0
newarray << val1 if sum == 0

j = j+1

end
i = i+1

end

p newarray

#comment. the above give me the right answer which is -1 and 1…but it
doesnt give me 3 and -3…i need 3 and -3 also…how i do that
#comment. so it stop after finding the first two numbers that add to
zero…how do i make it keep going till the end of array…it should
include 3 and -3.

I think you meant to have one of the 3s be positive in your data array

data=[0,1,2,-1,3,-4,-6,-3]

same code gave me this result [-1, 1, -3, 3]

thanks man lol…i slept at 3am last nite…

That’s nothing dude, must of us don’t sleep, just coffee coffee
coffee…