I need to get result after array loop is completed and do something with this result in Node Js project count
and I need to check this variable after loop is completed
var count = 0;
myArray.forEach(element => {
if(element == 'something'){
count++;
}
});
if(count == 2){
// do smth
}else if(count == 1){
// do something else
}else{
// or do this
}
currently if
statement is being implemented before I get result from loop.