0

I want no commas to appear when this code comes out, what do I do?

n=prompt("Put something") function validate(n){ return n.match(/[aeiou]/gi) } console.log(validate(n))

21st Jul 2020, 6:42 PM
Juancho
Juancho - avatar
1 ответ
+ 6
"".match returns an array. Use [].join method. Also notice the match returns null when a match is not found. You should check for null to prevent errors. And remember to always use var/let/const when declaring variables! var val = validate(n); if(val === null){ console.log("Vowel not found"); }else{ console.log(val.join(" ")); }
21st Jul 2020, 7:23 PM
Kevin ★