Edabit

Write a function that takes a string as an argument and returns a list of all the words inflected by "-ing". Your function should also exclude all the mono-syllabic words ending in "-ing" (e.g. bing, sing, sling, ...). Although these words end in "-ing", the "-ing" is not an inflection affix.

Examples

 ingExtractor("coming bringing Letting sing") ➞ ["coming", "bringing", "Letting"]  ingExtractor("going Ping, king sHrink dOing") ➞ ["going",, "dOing"]  ingExtractor("zing went ring, ding wing SINk") ➞ [] 

Notes

  • Mono-syllabic means a word containing just one syllable.
  • It's probably best to use RegEx for this challenge.

Solution:

 1  2  3  4  5  6  7  8  9 10 11 12 13 14
function ingExtractor(string) {   return string     .replace(/[^a-zA-Z ]/g, "")     .split(" ")     .filter((word) => {       let temp = word.toLowerCase().replace("ing", "");       if (temp.length === temp.replace(/[aeiou]/g, "").length) {         return false;       }       if (word.toLowerCase().includes("ing")) {         return true;       }     }); } 

This free site is ad-supported. Learn more