title: how to use javascript functions?
body: <p>I have a function to encode strings(I found it from net), and its javascript. but I'm not familiar with js so please help to use this!</p>
  
  <p>this the code:</p>
  
  <pre><code>function encode($string) {
  var one=new Array([1,1,1],[1,0,1],[1,0,0],[0,0,1]);
  var zero=new Array([0,1,0],[1,1,0],[0,1,1],[0,1,0],[0,0,0]);
  var a=new Array();var b=new Array();var c=new Array();
  var i;for($i=0;$i&lt;$string.length;$i++) a[$i]=$string.charAt($i);
  for($i=0;$i&lt;a.length;$i++) a[$i]=a[$i].charCodeAt(0);
  for($i=0;$i&lt;a.length;$i++) {
     b[$i]=new Array();$j=0;
     while(a[$i]) {
         b[$i][$j++]=a[$i]%2;a[$i]=parseInt(a[$i]/2);} 
     if($j&lt;8) for($k=$j;$k&lt;8;$k++) b[$i][$k]=0;} 
  for($i=0;$i&lt;b.length;$i++) for($j=0;$j&lt;8;$j++) 
     b[$i][$j]=(b[$i][$j]==0)?(zero[(parseInt(Math.random()*10))%5]):(one[(parseInt(Math.random()*10))%4]);
  var l=b.length;for($j=0;$j&lt;8;$j++) for($k=0;$k&lt;3;$k++) for($i=0;$i&lt;l;$i++) c[$k*l+$i+$j*3*l]=b[$i][$j][$k];
  var fString="";
  for($i=0;$i&lt;l*3;$i++) {
     var a=0;for($j=0;$j&lt;8;$j++) a+=c[$j+$i*8]*exp(2,$j);fString+="|"+a;} 
  return fString;}
  </code></pre>
  
  <p>as you see this function encode strings and I need this encoded string in a php get request method:</p>
  
  <pre><code>"http://example.com/?id="+encode(getId())+"&amp;t="+Math.random()
  </code></pre>
  
  <p>I don't know how to give a string to js functions, please help me by an example of giving some string and at last explain Math.Random() that how much is its range!</p>