Ad

same method but shorter

Code
Diff
  • n=s=>[...s].map(e=>("aeiou".includes(e)?"aeiou".indexOf(e)+1:e)).join('')
    d=s=>[...s].map(e=>("12345".includes(e)?"aeiou"[e-1]:e)).join('')
    
    • function encode(string){
    • return [...string].map(el => {return ( "aeiou".includes(el))? "aeiou".indexOf(el) + 1 : el}).join('')}
    • function decode(string){
    • return [...string].map(el => {return ("12345".includes(el)) ? {'1':"a","2":"e","3":"i","4":"o","5":"u"}[el] : el}).join('')
    • }
    • n=s=>[...s].map(e=>("aeiou".includes(e)?"aeiou".indexOf(e)+1:e)).join('')
    • d=s=>[...s].map(e=>("12345".includes(e)?"aeiou"[e-1]:e)).join('')

needs little work LOL

Code
Diff
  • r=(a,b)=>a==b?'Draw':`Player ${((a.charCodeAt(3)-b.charCodeAt(3))/3 > 0)+1} wins`
    • dumbRockPaperScissors=(a,b)=>a==b?`Draw`:`Player ${(a.slice(0,1)!={'R':'P','P':'S','S':'R'}[b.slice(0,1)])+1} wins`
    • r=(a,b)=>a==b?'Draw':`Player ${((a.charCodeAt(3)-b.charCodeAt(3))/3 > 0)+1} wins`

that's called "thinking outside the box"

Code
Diff
  • dumbRockPaperScissors=(a,b)=>a==b?`Draw`:`Player ${(a.slice(0,1)!={'R':'P','P':'S','S':'R'}[b.slice(0,1)])+1} wins`
    
    • dumbRockPaperScissors
    • =(a,b)=>
    • a==b?`Draw`:`Player ${(a!={'Rock':'Paper','Paper':'Scissors','Scissors':'Rock'}[b])+1} wins`
    • dumbRockPaperScissors=(a,b)=>a==b?`Draw`:`Player ${(a.slice(0,1)!={'R':'P','P':'S','S':'R'}[b.slice(0,1)])+1} wins`
Strings

Can't beat this can you? 😏

Code
Diff
  • isUnique=s=>new Set(s).size===s.length
    • isUnique = s => s.split("").filter((a,b,c) => c.indexOf(a) === b).length == s.length;
    • isUnique=s=>new Set(s).size===s.length
Code
Diff
  • m=x=>['codewarz','abracadabra!'][+x];
    
    • const magick_message = x => ['codewarz', 'abracadabra!'][+x];
    • m=x=>['codewarz','abracadabra!'][+x];
const areAnagrams = (word1, word2) => {
  const clean = str => str.replace(/\s/g, '').toLowerCase();
  const count = str => Array.from(clean(str)).reduce((map, char) => map.set(char, (map.get(char) || 0) + 1), new Map());

  const map1 = count(word1);
  const map2 = count(word2);

  return Array.from(map1.keys()).every(char => map1.get(char) === map2.get(char));
};
Fundamentals
Strings
Code
Diff
  • reverseStr=s=>[...s].reverse().join('')
    • var reverseStr=s=>[...s].reverse().join('')
    • reverseStr=s=>[...s].reverse().join('')
Fundamentals
Strings

there's a shorter way, but same steps as my previous kumite.

Code
Diff
  • var reverseStr=s=>[...s].reverse().join('')
    • const reverseStr=s=>s.split("").reverse("").join("");
    • var reverseStr=s=>[...s].reverse().join('')
Fundamentals
Strings

transform array to string by .split(""), reverse it then make it string again by .join("")

Code
Diff
  • const reverseStr=s=>s.split("").reverse("").join("");
    • const reverseStr = s => {
    • let ss = "";
    • for (let i = s.length-1; i >= 0; i--) {
    • ss += s[i];
    • }
    • return ss;
    • }
    • console.log(reverseStr("Lorem ipsum dolor sit amet!"))
    • const reverseStr=s=>s.split("").reverse("").join("");