Skip to content
Advertisement

Tag: function

How to find longer Strings from an Array?

I want to find Longer Strings from this array: const myArr = [“first”, “second”, “third”, “fourth”, “fifth”, “sixth”, “seven”, “eighth”] in this array “second”,”fourth”,”eighth” has length of 6. I want to return these in an array. expected output is: [“second”,”fourth”,”eighth”] but returns =[“first”,”second”] Answer Easier if you use filter instead: That returns: Or, as Sash mentions below, it can be

Using regex to get all consonants until a vowel appears

I’m trying to create a higher order function that would do two things. First: it would check the first letter of a string if it’s a vowel, if it is, it would append at the end of the string ‘way’. I’ve done so with this code: Then I need to code to run a specific task while checking for consonants

Advertisement