# Do you know "JS pointer" ? I have got AC,but I don't know WHAT's wrong in my Wrong Answer

• First ,the Wrong Answer, very same with my AC answer only 4 line not same

``````function reverse(head, k,last,result){

while((i>1)&&(p)&&(p.next)){
i--;

p=p.next;
}

if(i>1){
if(last){
}

return [null,null,result];
}
debugger;

ps=p;
i=k;
result=p;
}
var save=null;

//var list=[0,12,34,56,79];
while(i>1){

save=p.next;
p.next=start;
start=p;
p=save;
i--;
}
if(last!=null){
last.next=ps;
}
}
var reverseKGroup = function(head, k) {
if((k==1)||(k==0)){
}

//check single-node list;
//转

last=reverse(last[1],k,last[0],result);//not same with the AC answer
if(last[0]==null){//not same with the AC answer
break;
}
}
return result;//not same with the AC answer
};
``````

``````function reverse(head, k,last,result){

while((i>1)&&(p)&&(p.next)){
i--;

p=p.next;
}

if(i>1){
if(last){
}

return [null,null,result];
}
debugger;

ps=p;
i=k;
result=p;
}
var save=null;

//var list=[0,12,34,56,79];
while(i>1){

save=p.next;
p.next=start;
start=p;
p=save;
i--;
}
if(last!=null){
last.next=ps;
}
}
var reverseKGroup = function(head, k) {
if((k==1)||(k==0)){
}

//check single-node list;