4. Ten Simple JavaScript Exercises

1 of 10 simple JavaScript exercises. http://www.ling.gu.se/~lager/kurser/webtechnology/lab4.html JavaScript Exercise: 4. Write a function translate() that will translate a text into "rövarspråket". That is, double every consonant and place an occurrence of "o" in between. For example, translate("this is fun") should return the string "tothohisos isos fofunon".

by sebastiantatv

HTML

<h1>Hello Ludovic Ceccotti </h1>

<hr />

<h3>JavaScript Exercise:</h3>

<p>
  Write a function translate() that will translate a text into "rövarspråket". That is, double every consonant and place an occurrence of "o" in between. For example, translate("this is fun") should return the string "tothohisos isos fofunon".
</p>

<hr />

<h3>Console Log Out:</h3>

<div id="console-log"></div>

<hr />

JavaScript

//Hack to mimic console within JSFiddle
var consoleLine = "<p class=\"console-line\"></p>";
console = {
    log: function (text) {
        $("#console-log").append($(consoleLine).html(text));
    }
};
 var consonants = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z'];

console.log('Original string is: this is fun')
console.log('The separator is: "o"')
console.log('The "rövarspråket" should be: "tothohisos isos fofunon"')