Возникает ошибка в стрелочной функции js
Есть функция, она работает корректно, но, стоит перевести ее в стрелочную, как выдает ошибку, не могу понять иза чего этот баг.
function findVowels(str) {
let test = str.match(/[aeiou]/g)
return test ? test.length : 0;
}
console.log(findVowels('hello'));
console.log(findVowels('why'));
function findVowels(str) => {
let test = str.match(/[aeiou]/g)
return test ? test.length : 0;
}
console.log(findVowels('hello'));
console.log(findVowels('why'));
Ответы (1 шт):
Автор решения: Igor
→ Ссылка
const findVowels = (str) => {
let test = str.match(/[aeiou]/g)
return test ? test.length : 0;
}
console.log(findVowels('hello'));
console.log(findVowels('why'));