Match method help

Dear all,
I have been trying to use a match method in an exercise of hackerrank .
It seems the parameter I am giving to the exercise is not defined.
Can anyone help me please:
The parameter is word .

function vowelsAndConsonants(word){
    let vowels = word.match(/[o]/gi);
    for(let value of vowels){
        console.log(value);
    }
    let consonants = s.match(/[wrd]/gi);
    for(let value of consonants){
        console.log(value);
    }
    
}

console.log(vowelsAndConsonants(word));

s is not defined. What are you trying to match here?

Also, when you call the function, you should be passing a string. You’re essentially passing an undefined variable (word), so the function can’t do anything with it.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.