Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f48822f

Browse files
fiveth commit
1 parent 81e0035 commit f48822f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎beginner/ex10.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Have the function letterChanges(str) take the str parameter being passed and
3+
* modify it using the following algorithm. Replace every letter in the string
4+
* with the letter following it in the alphabet (ie. c becomes d, z becomes a).
5+
* Then capitalize every vowel in this new string (a, e, i, o, u) and finally
6+
* return this modified string.
7+
*/
8+
9+
function LetterChanges (str) {
10+
let alpha = 'abcdefghijklmnopqrstuvwxyz';
11+
let newAlpha = 'bcdEfghIjklmnOpqrstUvwxyzA';
12+
let answer = '';
13+
14+
for (let i = 0; i < str.length; i++) {
15+
let index = alpha.indexOf(str[i]);
16+
if (index !== -1) {
17+
answer += newAlpha[index];
18+
} else {
19+
answer += str[i];
20+
}
21+
}
22+
return answer;
23+
}
24+
console.log(LetterChanges("abc"));

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /