Ad
Code
Diff
  • const longestString = str => str.split(' ').reduce((a, b) => b.length > a.length ? b : a);
    • var longestString = (str) => str.split(' ').sort((a, b) => b.length - a.length)[0];
    • 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);
    }
    • function testAmount(sentence,letters){
    • var a=[];
    • for(var i=0;i<letters.length;i++){
    • a.push(0);
    • for(var j=0;j<sentence.length;j++){
    • if(sentence[j] == letters[i]){
    • a[i]++;
    • }
    • }
    • }
    • return a;
    • function testAmount(sentence, letters) {
    • return letters.map(letter => sentence.match(RegExp(letter, 'g')).length);
    • }