1

Есть функция, она работает корректно, но, стоит перевести ее в стрелочную, как выдает ошибку, не могу понять иза чего этот баг.

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'));

2

1 ответ 1

0

const findVowels = (str) => {
   let test = str.match(/[aeiou]/g)
   return test ? test.length : 0;
}

console.log(findVowels('hello'));
console.log(findVowels('why'));

2
  • Спасибо) странно, почему в моем варианте она не работала? Ведь так тоже можно объявлять?
    – salco2012
    31 мая 2021 в 20:40
  • @salco2012 так нельзя объявлять
    – user176262
    31 мая 2021 в 20:41

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.