Answer to Question #331960 in HTML/JavaScript Web Application for sandhya

Question #331960

words with vowels

The goal of this coading exam is to quickly get you off the ground with the array method filter().

given vowel list in the prefilled code and wordList as input,write a js program to,

filrer the words from wordslist with at least one vowel in it

log the array containning the filtered words in the console

input:

['Sword' , 'Myth' , 'Patient', 'Rhythm']

output:

['Sword', 'Patient']

input:

['Road' , 'Printer' , 'Eye' , 'Hymn']

output:

['Road' , 'Printer' , 'Eye' ]



1
Expert's answer
2022-04-21T18:06:32-0400
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
    <script>
        let arr1 = ['Sword' , 'Myth' , 'Patient', 'Rhythm'];
        let arr2 = ['Road' , 'Printer' , 'Eye' , 'Hymn'];


        vowelListFilter(arr1);
        vowelListFilter(arr2);


        function vowelListFilter(arr) {
            let res = arr.filter(item => {
                let test = false;


                for (let i = 0; i < item.length; i++) {
                    if (['a', 'e', 'i', 'o', 'u'].includes(item[i].toLowerCase())) {
                        test = true;
                    }
                }


                return test;
            })


            console.log(res);
        }
    </script>
</body>
</html>

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS