This ‘works’, but I am being told that my else statement’s variables are out of scope or that the variables have already been defined. Is this a large problem or a small problem.
function palindrome(str) {
str.toLowerCase();
var x = str.replace(/\W+/g, "");
var length = x.length;
var middle = (length/2);
if (length % 2 !== 0){
var a = (x.substring(0, middle));
var b = (x.substring(middle + 1));
} else {
a = (x.substring(0, middle));
b = (x.substring(middle));
}