Answer the question
In order to leave comments, you need to log in
How to get to rebuild the array to get such data?
I don’t understand how to do it easier, maybe you can help.
I created 2 cycles with a promise (Promise.all), after each bypass I wanted to delete the first element of the array, but then I realized that it wouldn’t work and I got confused))
There is an array with words, just for clarity letters left
[
"a",
"b",
"c"
]
[
"a - b",
"a - c",
"b - c"
]
return Promise.all(t.map(async e => {
return Promise.all(t.map(async e2 => {
if(e !== e2) return `${e} - ${e2}`
})).then(e => {
return e.splice(e.indexOf(undefined)+1)
}).then(e => {
return console.log(e)
})
}))
Answer the question
In order to leave comments, you need to log in
data.reduce((acc, curr, i) => [...acc, ...data.slice(i + 1).map((item) => `${curr} - ${item}`)], []);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question