I have this:
var mergeUniqueItems = ["-JsDEcxz_ZSGFLKwd1QM",
"-JsJ2NXGDYKI6QRsuXVK",
"-JsJ2RK-kOG2eGcG04xF",
"-JsJ2RK-kOG2eGcG04xF",
"-JsJ2YLPiP6751zh8geS"]
I have used this:
var duplicateArray = [];
for (var i = 0; i < mergeUniqueItems.length; i ++){
for (var j = 1; j < mergeUniqueItems.length; j ++){
if (mergeUniqueItems[i] == mergeUniqueItems[j]){
duplicateArray.push(mergeUniqueItems[i]);
}
}
}
console.log(duplicateArray);
Result has turn to be like this:
["-JsJ2NXGDYKI6QRsuXVK",
"-JsJ2RK-kOG2eGcG04xF",
"-JsJ2RK-kOG2eGcG04xF",
"-JsJ2RK-kOG2eGcG04xF",
"-JsJ2RK-kOG2eGcG04xF",
"-JsJ2YLPiP6751zh8geS"]
When my expectation is duplicate items in 1 array like below:
["-JsJ2RK-kOG2eGcG04xF"]
If there are more than one duplicate value, array should be like this:
["-JsJ2RK-kOG2eGcG04xF", "another_duplicate_1", "another_duplicate_2", ...]
I don't really know what's wrong with my code, please kindly help.
Thanks