function test() { var selected = false; selected = SCOPE.list_model.selected_items.length != 0 && true; var hasSumit = false; SCOPE.list_model.selected_items.forEach(function (item) { item.approve_state === 1 && item.message.info_state === 3 && (hasSumit = true); }); return !selected || hasSumit } var SCOPE = { "list_model": { "selected_items": [ { "message": { "info_state": 3 }, "approve_state": 1 } ] } } var result = test(); console.log(result)