//will stop the loop if the array has any negative number and return all the positive numbers before the negative numbers
function positiveNums(nums){
numbers = [];
for(var i=0;i<nums.length;i++){
if(nums[i]<0){
break;
}
else{
numbers.push(nums[i]);
}
}
return numbers;
}
var numbers = [1,2,3,4,5,6,7,43,-1,45,2,3,4,6,7,3];
console.log(positiveNums(numbers));