Code
Diff
  • const longestString = str => str.split(' ').reduce((a, b) => b.length > a.length ? b : a);
  • 1var longestString = (str) => str.split(' ').sort((a, b) => b.length - a.length)[0];
    1+const longestString = str => str.split(' ').reduce((a, b) => b.length > a.length ? b : a);
Code
Diff
  • function testAmount(sentence, letters) {
      return letters.map(letter => sentence.match(RegExp(letter, 'g')).length);
    }
  • 1function testAmount(sentence,letters){
    2 var a=[];
    3 for(var i=0;i<letters.length;i++){
    4 a.push(0);
    5 for(var j=0;j<sentence.length;j++){
    6 if(sentence[j] == letters[i]){
    7 a[i]++;
    8 }
    9 }
    10 }
    11 return a;
    1+function testAmount(sentence, letters) {
    2+ return letters.map(letter => sentence.match(RegExp(letter, 'g')).length);
    1212 }