I am very new to JavaScript. Presently, I am doing a Program where I want to translate a text into "rovarspracket". i.e) Double every consonant and place an occurrence of "o" in between. For ex: , translate("this is fun") should return the string "tothohisos isos fofunon" . I am not able to get the result as desired. Help me that i would learn.
This is my following code which i tried.
<button type="button" onclick="translate('de')">try it</button>
<h2 id="ad" />
<script>
function translate(t)
{//alert(t.length);exit;
var l=t.length;
var v=["a","e","i","o","u",""];
var b="";
for(var i=0;i<l;i++)
{ //alert(i);exit;
var c=t.charAt[i];alert(c);
if(v.indexOf(c)!=-1)
{
b=(b+(c));
}
else
{
b=(b+(c="o"+c));
}
}
document.getElementById("ad").innerHTML=b;
}
</script>