Answer the question
In order to leave comments, you need to log in
Why does the function continue executing statements after return true?
I ran into a problem when writing a function to check a string for a polyndrom (a string that reads the same from right to left and left to right)
The function continues to work after the return true statement...
https://codepen.io/B2o5T/pen/GQobKa
Answer the question
In order to leave comments, you need to log in
The function continues after the return true statement
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')
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question