I have a task to make the function, which will find the next palidrome of the input value and return the object with will include the value and how many steps was made. I made the task, but now I need to make it via recursion. Can U help me, how to update the code. Thanks.
<script>
polindrom = (num) => {
const object = {
'result': null,
'step': 1
}
let reverse = Number(num.toString().split('').reverse().join(''));
let sum = num + reverse;
while (sum !== Number(sum.toString().split('').reverse().join(''))) {
object.step++;
sum = sum + Number(sum.toString().split('').reverse().join(''));
}
object.result = sum;
return object;
}
</script>