constword="codewarriors"functionfindLongestVowels(word){constregex=/[aeiou]/;constvowels=Array.prototype.reduce.call(word,(currentLetters,nextLetter,index)=>{if(regex.test(nextLetter)){returnregex.test(word[index-1])?currentLetters.concat('',nextLetter):currentLetters.concat('',nextLetter);}else{returncurrentLetters;}},"");constlongestVowels=vowels.split('').reduce((longest,current)=>{returncurrent.length>longest.length?current:longest;},"");returnlongestVowels.length;}console.log("Length of the longest vowel: "+findLongestVowels(word));
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Javascript with reduce