Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Commonmark migration
Source Link

You can use reduce() and Set combination for example. Read from the docs:

The Set object lets you store unique values of any type, whether primitive values or object references.

The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in single output value.

Please see a possible working solution.

const array = ['business>management', 'News>Entertainment News', 'business>Entrepreneurship'];
const result = array.reduce((a,c) => {
 c.split('>').forEach(e => a.add(e));
 return a;
}, new Set());
const unique = Array.from(result);
console.log(unique);

I hope that helps!

You can use reduce() and Set combination for example. Read from the docs:

The Set object lets you store unique values of any type, whether primitive values or object references.

The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in single output value.

Please see a possible working solution.

const array = ['business>management', 'News>Entertainment News', 'business>Entrepreneurship'];
const result = array.reduce((a,c) => {
 c.split('>').forEach(e => a.add(e));
 return a;
}, new Set());
const unique = Array.from(result);
console.log(unique);

I hope that helps!

You can use reduce() and Set combination for example. Read from the docs:

The Set object lets you store unique values of any type, whether primitive values or object references.

The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in single output value.

Please see a possible working solution.

const array = ['business>management', 'News>Entertainment News', 'business>Entrepreneurship'];
const result = array.reduce((a,c) => {
 c.split('>').forEach(e => a.add(e));
 return a;
}, new Set());
const unique = Array.from(result);
console.log(unique);

I hope that helps!

edited body
Source Link
Fred
  • 3.5k
  • 4
  • 38
  • 59

You can use reduce() and Set combination for example. Read from the docs:

The Set object lets you store unique values of any type, whether primitive values or object references.

The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in a single output value.

Please see a possible working solution.

const array = ['business>management', 'News>Entertainment News', 'business>Entrepreneurship'];
const result = array.reduce((a,c) => {
 c.split('>').forEach(e => a.add(e));
 return a;
}, new Set());
const unique = Array.from(result);
console.log(unique);

HopeI hope that helps!

You can use reduce() and Set combination for example. Read from the docs:

The Set object lets you store unique values of any type, whether primitive values or object references.

The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in a single output value.

Please see a possible working solution.

const array = ['business>management', 'News>Entertainment News', 'business>Entrepreneurship'];
const result = array.reduce((a,c) => {
 c.split('>').forEach(e => a.add(e));
 return a;
}, new Set());
const unique = Array.from(result);
console.log(unique);

Hope that helps!

You can use reduce() and Set combination for example. Read from the docs:

The Set object lets you store unique values of any type, whether primitive values or object references.

The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in single output value.

Please see a possible working solution.

const array = ['business>management', 'News>Entertainment News', 'business>Entrepreneurship'];
const result = array.reduce((a,c) => {
 c.split('>').forEach(e => a.add(e));
 return a;
}, new Set());
const unique = Array.from(result);
console.log(unique);

I hope that helps!

Source Link
norbitrial
  • 15.2k
  • 10
  • 39
  • 66

You can use reduce() and Set combination for example. Read from the docs:

The Set object lets you store unique values of any type, whether primitive values or object references.

The reduce() method executes a reducer function (that you provide) on each element of the array, resulting in a single output value.

Please see a possible working solution.

const array = ['business>management', 'News>Entertainment News', 'business>Entrepreneurship'];
const result = array.reduce((a,c) => {
 c.split('>').forEach(e => a.add(e));
 return a;
}, new Set());
const unique = Array.from(result);
console.log(unique);

Hope that helps!

lang-js

AltStyle によって変換されたページ (->オリジナル) /