Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function vowelDoubler (array) {
- var vowels = {a: 'a', e: 'e', i: 'i', o: 'o', u: 'u'};
- var vowelCount = 0;
- for (var j = 0; j < array.length; j++) {
- if (array[j] in vowels) {
- vowelCount ++;
- }
- }
- // console.log('vowelCount ', vowelCount);
- for (var i = array.length - 1; i >= 0; i --) {
- if (array[i] in vowels) {
- array[i + vowelCount] = array[i];
- array[i + vowelCount - 1] = array[i];
- vowelCount --;
- } else {
- array[i + vowelCount] = array[i];
- }
- }
- return array;
- }
- console.log(vowelDoubler(['a', 'c', 'b', 'e', 'f']));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement