0

I have an output of words, but they are repeated, I need to exclude repetitions, so that the output would be the same format (STRING) that I entered.

For example:

i use, sequelize database and map:

const myreqdb = await Model.findall();
myreqdb.map((v) => {
console.log(v.status.split('_')[0]) 
console.log(v.status) 
//ok
//ok
//ok_false
//ok_true
//no
//no_false
//no_true
//db_true
//ff_false
console.log(v.status.split('_')[0]) 
//ok
//ok
//ok
//ok
//no
//no
//no
//db
//ff
})

I need an exit like this:

ok
false
db
ff

this is a quick example, the titles are quite different and there are more of them.

1 Answers1

0

you could use by fnxt/array/uniqueBy:

npm i fnxt

import { uniqueBy } from 'fnxt/array';
let words = ['a','b','a']
let uniqueWords = uniqueBy((item) => item)(words)
YAMM
  • 572
  • 4
  • 9