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'
1 function capitalise([first, ...rest]) {
2 return first.toUpperCase() + rest.join('');
3 };
4 capitalise('hello'); // 'Hello'
5
1 "Hello World".split("").reverse().join("") // 'dlroW olleH'
1 function randomString() {
2 const mathRandom = Math.random().toString(16).slice(2, 7);
3 const dateRandom = Date.now().toString().slice(7);
4
5 return mathRandom + dateRandom;
6 }
7
8 randomString(); // 'a35cb487380'