javascript - Array filter to return a string -
i have array , using filter function arrays check duplicates:
var array = [hello, world, hello, hi, how you]; var uniquearray = array.filter(function(item, pos) { return array.indexof(item) == pos; }); return uniquearray.join(",");
now return unique array string , unknown reason failing. documentation, shows returns array how can convert unique array string?
add quotes strings !
var array = ['hello', 'world', 'hello', 'hi', 'how you']; var uniquearray = array.filter(function(item, pos) { return array.indexof(item) === pos; }); return uniquearray.join(",");
Comments
Post a Comment