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))
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(" "));
}