dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
78 lines
1.4 KiB
Markdown
78 lines
1.4 KiB
Markdown
---
|
|
id: 69306364df283fcaff2e1ada
|
|
title: "Challenge 149: vOwElcAsE"
|
|
challengeType: 28
|
|
dashedName: challenge-149
|
|
---
|
|
|
|
# --description--
|
|
|
|
Given a string, return a new string where all vowels are converted to uppercase and all other alphabetical characters are converted to lowercase.
|
|
|
|
- Vowels are `"a"`, `"e"`, `"i"`, `"o"`, and `"u"` in any case.
|
|
- Non-alphabetical characters should remain unchanged.
|
|
|
|
# --hints--
|
|
|
|
`vowelCase("vowelcase")` should return `"vOwElcAsE"`.
|
|
|
|
```js
|
|
assert.equal(vowelCase("vowelcase"), "vOwElcAsE");
|
|
```
|
|
|
|
`vowelCase("coding is fun")` should return `"cOdIng Is fUn"`.
|
|
|
|
```js
|
|
assert.equal(vowelCase("coding is fun"), "cOdIng Is fUn");
|
|
```
|
|
|
|
`vowelCase("HELLO, world!")` should return `"hEllO, wOrld!"`.
|
|
|
|
```js
|
|
assert.equal(vowelCase("HELLO, world!"), "hEllO, wOrld!");
|
|
```
|
|
|
|
`vowelCase("git cherry-pick")` should return `"gIt chErry-pIck"`.
|
|
|
|
```js
|
|
assert.equal(vowelCase("git cherry-pick"), "gIt chErry-pIck");
|
|
```
|
|
|
|
`vowelCase("HEAD~1")` should return `"hEAd~1"`.
|
|
|
|
```js
|
|
assert.equal(vowelCase("HEAD~1"), "hEAd~1");
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```js
|
|
function vowelCase(str) {
|
|
|
|
return str;
|
|
}
|
|
```
|
|
|
|
# --solutions--
|
|
|
|
```js
|
|
function vowelCase(str) {
|
|
const vowels = "aeiouAEIOU";
|
|
let result = "";
|
|
|
|
for (let char of str) {
|
|
if (vowels.includes(char)) {
|
|
result += char.toUpperCase();
|
|
} else if (/[a-zA-Z]/.test(char)) {
|
|
result += char.toLowerCase();
|
|
} else {
|
|
result += char;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
```
|