function Xbonacci(signature,n){
  var next = 0, count = 0, sigCopy = signature.slice(), first;
    switch(signature.length){
        case 0:
        case 1:
            return signature;
        case 2:
        for (var x = 0; x < signature.length; x++){
            next = signature[x] + signature[x+1];
            signature.push(next);
            if(signature.length === n)
                break;
        }
            return signature;
        default:
            while (count <= n){
            //console.log("Signature Copy " + sigCopy + " Signature: " + signature);
            next = sigCopy.reduce(function(a,b){return a+b;});
            signature.push(next);
            ++count;
            //copy the new array and remove the first element
            sigCopy = signature.slice();
            first = sigCopy.shift();
            if (signature.length == n)
                break;
        }
            return signature;
    }
}

@@ -1,16 +1,22 @@
+/*/*/%0A
 function Xbonacc
@@ -100,16 +100,10 @@
 ;%0A  
-  switch
+if
 (sig
@@ -119,93 +119,104 @@
 ngth
-)%7B%0A        case 0:%0A        case 1:%0A            return signature;%0A        case 2:%0A    
+ === 1 %7C%7C signature.length === 0)%7B%0A    return signature;%0A  %7D%0A  else if(signature.length === 2)%7B%0A
     
@@ -261,30 +261,24 @@
 x++)%7B%0A      
-   
-   
 next = signa
@@ -303,22 +303,16 @@
 e%5Bx+1%5D;%0A
-      
       si
@@ -337,22 +337,16 @@
 ;%0A      
-  
-    
 if(signa
@@ -368,32 +368,24 @@
  n)%0A        
-       
- 
 break;%0A     
@@ -387,184 +387,65 @@
     
-    %7D%0A            return signature;%0A        default:%0A            while (count %3C= n)%7B%0A            //console.log(%22Signature Copy %22 + sigCopy + %22 Signature: %22 + signature);%0A      
+%7D%0A  %7Delse%7B%0A    for(var x = 0; x %3C signature.length;x++)%7B%0A
     
@@ -479,16 +479,17 @@
 ction(a,
+ 
 b)%7Bretur
@@ -498,22 +498,16 @@
 a+b;%7D);%0A
-      
       si
@@ -530,97 +530,8 @@
 t);%0A
-            ++count;%0A            //copy the new array and remove the first element%0A      
     
@@ -567,22 +567,16 @@
 ;%0A      
-  
-    
 first = 
@@ -596,22 +596,16 @@
 ();%0A
-      
       if
  (si
@@ -600,17 +600,16 @@
       if
- 
 (signatu
@@ -620,28 +620,22 @@
 ength ==
+=
  n)
+%7B
 %0A
-        
         
@@ -651,22 +651,21 @@
     
- 
- 
 %7D%0A    
-      
+%7D%0A  %7D%0A%0A
   re
@@ -684,12 +684,275 @@
 re;%0A
-    %7D%0A%7D
+%7D%0A%0ATest.assertSimilar(Xbonacci(%5B0,1%5D,10),%5B0,1,1,2,3,5,8,13,21,34%5D)%0ATest.assertSimilar(Xbonacci(%5B1,1%5D,10),%5B1,1,2,3,5,8,13,21,34,55%5D)%0ATest.assertSimilar(Xbonacci(%5B0,0,0,0,1%5D,10),%5B0,0,0,0,1,1,2,4,8,16%5D)%0ATest.assertSimilar(Xbonacci(%5B1,0,0,0,0,0,1%5D,10),%5B1,0,0,0,0,0,1,2,3,6%5D)
 %0A

Update xbonacci function