I am getting error while checking any object has some value from one array using Javascript. I am explaining my code below.
let arr = [
{
"config": "as",
"payload": ""
},
{
"config": "as",
"payload": "xc"
},
{
"config": "",
"payload": "xc"
},
{
"config": "",
"payload": ""
}
]
let isNext = true;
for(let i=0; i < arr.length; i++) {
if(arr[i].config !== '' || arr[i].payload !=='') {
isNext = false
return;
}else{
isNext = true;
}
}
console.log('next', isNext);
Here I have one array of object and each object has 2 key-value pair. I need inside array it will check if any one of object has some value for both config or payload then isNext will be false other wise it will be true. but as per this code I am getting the following error.
Uncaught SyntaxError: Illegal return statement"
Please help me to resolve this issue.
break, not return btw