I have the following array:
array-1:
Array[11]
0:"265"
1:"text-success"
2:"51"
3:"text-warning"
4:"16"
5:"text-warning"
6:"35"
7:"text-warning"
8:"38"
9:"text-warning"
10:"106"
array-2:
Array[11]
0:"265"
1:"text-success"
2:"51"
3:"text-warning"
4:"16"
5:"text-warning"
6:"35"
7:"text-success"
8:"38"
9:"text-warning"
10:"106"
array-3:
Array[11]
0:"265"
1:"muted"
2:"51"
3:"text-warning"
4:"16"
5:"text-warning"
6:"35"
7:"text-success"
8:"38"
9:"text-warning"
10:"106"
array-4:
Array[11]
0:"265"
1:"text-warning"
2:"51"
3:"text-warning"
4:"16"
5:"muted"
6:"35"
7:"text-warning"
8:"38"
9:"text-warning"
10:"106"
1st one will return FALSE because both exist "text-success"-twice AND "muted"-once
2nd one will return TRUE because it exist ONCE "text-success"
3rd one will return FALSE because both exist "text-success" AND "muted"
4th one will return TRUE because it exist ONCE "muted"
I need to parse the array and get the result:
array-1:
Array[11]
0:"265"
1:"text-success"
2:"51"
array-2: Null
array-3: Null
array-4:
Array[11]
0:"265"
1:"muted"
2:"16"
so far I have this:
function singles( array) {
for( var index = 0, single = []; index < array.length; index++ ) {
if(array[index] == "text-success" || array[index] == "muted") {
single.push(array[index]);
}
}
return single;
};
Please help anyone?