This function takes an array with some integers and my goal is to have a new array with just positive integers:
func domath(newarray[] int, i int, array[] int)([]int){
if i < len(newarray) {
if newarray[i] < 0{
i ++
domath(newarray, i, array)
}
if newarray[i] >= 0 {
array = append(array, newarray[i])
i ++
domath(newarray, i, array)
}
}
return array
}
However, I keep getting the same error saying panic:
runtime error: index out of range
Do you want write a recursive function?, you can see my code below :
}