1 const intersection = (a, b) => { 2 const bSet = new Set(b); 3 return a?.filter(value => bSet.has(value)); 4 } 5 6 intersection([1, 2, 3], [1, 3, 5]) // [1, 3]

Linkerin


1 function slugify(value) { 2 return value 3 .toString() 4 .normalize('NFD') // split an accented letter in the base letter and the accent 5 .replace(/[\u0300-\u036f]/g, '') // remove all the accents 6 .toLowerCase() 7 .replace(/[^a-z0-9 -]/g, '') // replace all chars that are not letters, numbers and spaces 8 .trim() 9 .replace(/\s+/g, '-');} 10 slugify('Hello world'); // 'hello-world'