Support Functions
Capitalizing the first letetr (Titlecase)
- Titlecase
- output
export const capitalize1stLetter = (words: string = 'unkown user') => {
const wordArray = words.split(' ');
const capitalArray: string[] = [];
wordArray.forEach(word => capitalArray.push(word.charAt(0).toUpperCase() + word.slice(1)));
return capitalArray.join(' ');
};
const mySkills = ['angular', 'Node Js', 'CSS'];
console.log(shuffleArrayEls(mySkills));
// Output
// ["CSS", "angular", "Node Js"]
Shuffling Array Elements
- Shuffle Logic
- output
const shuffleArrayEls = (skills: string[]) => {
return skills
.map(a => ({ sort: Math.random(), value: a }))
.sort((a, b) => a.sort - b.sort)
.map(a => a.value);
};
const myName = 'anand raja';
console.log(capitalize1stLetter(myName));
// Output
// Anand Raja