Created
February 18, 2018 17:08
-
-
Save arrbxr/db34313b2671f1b68a8ca7d11be491c5 to your computer and use it in GitHub Desktop.
Replace all vowel to exclamation mark in the sentence created by arrbxr - https://repl.it/@arrbxr/Replace-all-vowel-to-exclamation-mark-in-the-sentence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Replace all VOWEL to EXCLAMATION | |
function vowelReplace(str){ | |
// here we define vowel | |
var myStr = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']; | |
// here we convert string to array | |
var arr = str.split('') | |
// first loop start | |
for(i = 0; i < arr.length; i++){ | |
// second loop start | |
for(j = 0; j< myStr.length; j++){ | |
// we compare i and j | |
if(arr[i] == myStr[j]){ | |
// here vowel convert exclamation | |
arr[i] = "!"; | |
} | |
} | |
} | |
// here join() function replace array to string | |
return arr.join(''); | |
} | |
vowelReplace("Replace All vowel to exclamation"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// second method
function replace(s){
return s.replace(/[aeoiu]/ig, '!')
}