« Oatmeal

Olophont.js

In Lord of the Rings there are creatures that look like giant elephants. JRR Tolkien named these creatures olophonts…” simply replacing every vowel in the word elephant with an o. Here is a javascript function to do the same thing.

function olophont(string) {
  let replaceVowels = "";
  for (let i = 0; i < string.length; i++) {
    if (!'aeiou'.includes(string[i])) {
      replaceVowels += string[i];
    } else {
      replaceVowels += 'o';
    }
  }
  return replaceVowels;
}

console.log(olophont('elephant'));
console.log(olophont('banana'));
console.log(olophont('chimpanzee'));
console.log(olophont('fish'));