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.

3

1 Answer 1

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)
2
  • Hello, I don't want to use the library. Sorry Commented Jan 22, 2023 at 13:01
  • @user21059953 then lookup the source code
    – YAMM
    Commented Jan 22, 2023 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.