Why is the result of my calculation undefined?
<p>when I run the javascript code below, I get the variable original as ending as </p>

<pre><code>"1059823647undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefined0"
</code></pre>

<p>why is this happening and how can i fix it?</p>

<pre><code>original="012345678901234567890";
document.write("&lt;textarea&gt;");
document.write(original);
document.write("&lt;/textarea&gt;"+"&lt;br&gt;");

/* scramble */
var scramble='1059823647';
scramble=scramble.split('');

var scrambled=new Array();

original=original.split('');

for(i=0;i&lt;original.length;i++){
  if(Math.round(Math.round(Math.floor(i/10)*10)+10)&gt;=original.length){
    scrambled[i]=original[i];
  }else{
    scrambled[i]=original[Math.round(Math.round(Math.floor(i/10)*10)+scramble[i%10])];
  }
}

original='';

for(i=0;i&lt;scrambled.length;i++){
  original+=scrambled[i];
}

document.write("&lt;textarea&gt;");
document.write(original);
document.write("&lt;/textarea&gt;"+"&lt;br&gt;");
</code></pre>
