Why the function continues executing instructions after a return true?

Faced with the problem when you write a function to check the string on palindrom (string which reads the same from right-to-left and left-to-right)

The function continues after return statement true...

https://codepen.io/B2o5T/pen/GQobKa
June 8th 19 at 16:32
2 answers
June 8th 19 at 16:34
Solution
The function continues after return statement to true

No, not continues. That you think so, due to the recursive call. By the way, it too should be returned, i.e. instead of just
checkPalindrome(newStr);
must be
return checkPalindrome(newStr);

Oh and check for an empty string there.
Thank you, now everything became clear)) - richard.Bog commented on June 8th 19 at 16:37
June 8th 19 at 16:36
function checkPalindrome(inputString) {
 var p = inputString.split("),
 ch = p.slice().reverse();
 return p.toString() == ch.toString();
}

 console.log (
checkPalindrome('abcvvcba'),
checkPalindrome('abcvcba'),
checkPalindrome('bcbaaaa'),
checkPalindrome('aaa')
 );

Find more questions by tags JavaScript