Skip to content

Instantly share code, notes, and snippets.

@AminBusiness
Created November 9, 2018 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AminBusiness/ebadaa19226284fffe344700bdb749ab to your computer and use it in GitHub Desktop.
Save AminBusiness/ebadaa19226284fffe344700bdb749ab to your computer and use it in GitHub Desktop.
<script id="jsbin-javascript">
//Challenge 11
//Change every letter of the string to the one that follows it and capitalize the
//Vowels
function letterChanges(str){
let newStr = str.toLowerCase().replace(/[a-z]/gi, function(char)
{
if(char === 'z' || char === 'Z')
{
return 'a';
} else
{
return String.fromCharCode(char.charCodeAt() + 1);
}
});
newStr = newStr.replace(/a|e|i|o|u/gi, function(vowel) {
return vowel.toUpperCase();
});
return newStr;
}
const output = letterChanges('Hello There');
console.log(output);
</script>
<script id="jsbin-source-javascript" type="text/javascript">//Challenge 11
//Change every letter of the string to the one that follows it and capitalize the
//Vowels
function letterChanges(str){
let newStr = str.toLowerCase().replace(/[a-z]/gi, function(char)
{
if(char === 'z' || char === 'Z')
{
return 'a';
} else
{
return String.fromCharCode(char.charCodeAt() + 1);
}
});
newStr = newStr.replace(/a|e|i|o|u/gi, function(vowel) {
return vowel.toUpperCase();
});
return newStr;
}
const output = letterChanges('Hello There');
console.log(output);
</script>
//Challenge 11
//Change every letter of the string to the one that follows it and capitalize the
//Vowels
function letterChanges(str){
let newStr = str.toLowerCase().replace(/[a-z]/gi, function(char)
{
if(char === 'z' || char === 'Z')
{
return 'a';
} else
{
return String.fromCharCode(char.charCodeAt() + 1);
}
});
newStr = newStr.replace(/a|e|i|o|u/gi, function(vowel) {
return vowel.toUpperCase();
});
return newStr;
}
const output = letterChanges('Hello There');
console.log(output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment