I have a Javascript object (of indefinite size) where the value is an array of strings. For example :
var obj = {
"article1": ["john locke", "sawyer", "john Locke"] ,
"article2": ["person3", "person4"]
}
I want to transform so that any duplicate string is removed.
That means for the example above, I'd have
var finalObj = {
"article1": ["john locke", "sawyer"], //"john Locke" was removed"
"article2": ["person3", "person4"]
}
It has to be case insensitive, i.e john Locke should be removed if there is already at the start 'john locke".
How to achieve this ?
for (let k in obj){}"john locke" !== "john Locke"["john Locke", "john locke", "sawyer"], should the case of first occurrence of value to be maintained in output ?