check sum of the array is zero in the given array in javascript
<!DOCTYPE html>
<html>
<body>
<h2>My First JavaScript</h2>
<script>
function getdata(n){
let obj = {};
for(let value of n){
for(let i=1;i<=n.length;i++){
if(value + n[i] === 0){
return [value,n[i]];
}
}
}
}
var data = getdata([-5,-4,-3,-2,0,2,4,6,8]);
alert(data);
</script>
</body>
</html>
Thanks you for commenting your questions. I will see question and respond you.