I need assistance creating a walking robot function in JavaScript, but I am encountering a call stack size error.
function walk(meter) {
if(meter < 0) {
count = 0;
} else if(meter <= 2) {
count = meter;
} else if(meter == 3) {
count = walk(meter-1)+walk(meter-2)+1;
} else {
count = walk(meter-1)+walk(meter-2)+walk(meter-3);
}
return count;
}
console.log(walk(100));