반응형
Given an array of numbers, check if any of the numbers are the character codes for lower case vowels (a, e, i, o, u).
If they are, change the array value to a string of that vowel.
Return the resulting array.
Solution:
function isVow(a){
for (let index in a) {
let vow = String.fromCharCode(a[index])
if (["a", "e", "i", "o", "u"].includes(vow)) {
a[index] = vow
}
}
return a
}
const isVow = a => a.map(x=>'aeiou'.includes(y=String.fromCharCode(x)) ? y : x)
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
0108. How many lightsabers do you own? (0) | 2023.01.09 |
---|---|
0107. Exclamation marks series #4: Remove all exclamation marks from sentence but ensure a exclamation mark at the end of string (0) | 2023.01.07 |
0105. Greet Me (0) | 2023.01.05 |
0104. Sleigh Authentication (0) | 2023.01.04 |
0103. Powers of 2 (0) | 2023.01.03 |