We have a name value field , and its not accepting duplicate names .However in integration , its creating record using the duplicate names .How do we validate this to ignore duplicate names in the request
Asked
Active
Viewed 331 times
-1
-
Share your array. – Ankit Agarwal Jun 25 '18 at 11:29
-
2There are never duplicate keys in an array. – Jonas Wilms Jun 25 '18 at 11:30
-
Add "use strict"; to the top of your file. Which will throws a syntax error. – Sudhir Ojha Jun 25 '18 at 11:31
-
@JonasW. In an empty array, there's a duplicate for every key. :-O – bipll Jun 25 '18 at 11:31
-
Below is my array @AnkitAgarwal {"Speed": "1200","Speed": "4","Bandwidth": "100"} – Divya G Jun 25 '18 at 12:27
-
@DivyaG that is not a array. Edit your question and add the array there. – Ankit Agarwal Jun 25 '18 at 12:43
1 Answers
0
Use array filter to the removed duplicate values
const array = ["test", "test1", "test2", "test", "test", "test1", "test", "test2", "test"];
var uniqueArray = array.filter(function(elem, index, self) {
return index === self.indexOf(elem);
})
console.log(uniqueArray);

Mohammad Ali Rony
- 4,695
- 3
- 19
- 33