-2

Morning guys!

I need the vowels letters in upper case.

I've tried this but doesn't work:

let arr = ['1 abcde', '2 abcde', '3 abcde'];
let vowels = ['a','e','i','o','u'];
let list = [];

for(let item in arr){
    if(item in vogals){
    list.push(item.toUpperCase());
    }else{
    list.push(item.toLowerCase());
    }
}

I want this result:

//Expected result: 
arr = ['1 AbCdE', '2 AbCdE', '3 AbCdE']

Help me please!

Eduardo S
  • 17
  • 6

1 Answers1

-1

It should be probably something like this:

let arr = ['1 abcde', '2 abcde', '3 abcde'];
let vowels = ['a','e','i','o','u'];
const result = arr.map(str => [...str].map(char => vowels.includes(char) ? char.toUpperCase() : char).join(''))
console.log(result)
Konrad
  • 21,590
  • 4
  • 28
  • 64