gloriaJun / til

Lessoned Learned
3 stars 0 forks source link

Javascript Utility Code Tip #145

Open gloriaJun opened 2 years ago

gloriaJun commented 2 years ago

Generate Unique string key

const uid = () => {
   const val1 = Date.now().toString(36);
   const val2 = Math.random().toString(36).substr(2);
   return val1 + val2;
}
gloriaJun commented 2 years ago

Reverse String

const reverse = (txt) => {
   let text = txt;
   return text.split('').reverse().join('');
}