I have the following object in Javascript:
Array[11]
0:"532"
1:"text-warning"
2:"51"
3:"text-warning"
4:"16"
5:"muted"
6:"35"
7:"text-warning"
8:"38"
9:"text-warning"
10:"106"
Array[11]
0:"533"
1:"text-warning"
2:"51"
3:"text-warning"
4:"16"
5:"muted"
6:"35"
7:"text-success"
8:"38"
9:"text-warning"
10:"106"
Array[11]
0:"534"
1:"text-warning"
2:"51"
3:"text-warning"
4:"16"
5:"text-warning"
6:"35"
7:"text-success"
8:"38"
9:"text-warning"
10:"106"
I would like to parse it and find if two value exist only once within this array.
Example: "text-success" OR "muted" if EXIST ONCE return the array
if it EXIST twice return null
if TRUE return the corresponding id
In the above example:
1st Array: is TRUE
Array[11]
0:"532"
1:"muted"
2:"35"
2nd one is FALSE because its exist twice
3rd one: is also TRUE
Array[11]
0:"534"
1:"text-success"
2:"38"
I have been trying this past few days was not successful
I have the following JQUERY: but it only gets the Unique value but discard the others:
I need the first id and the corresponding id as well:
Array[11]
0:"534" -> main id (needed)
1:"text-success"
2:"38" -> company id (needed)
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;
};
The result or the output which is required:
Array[11]
0:"532",
1:"muted",
2:"35",
The first value is the Main ID, the 2nd value is the UNIQUE and the 3rd value is the corresponding ID for the unique value.
var o = { a: "foo", b: 42, c: {} };.