Hello everybody,
I have been checking the project of the Palindrome and I its working in all the questions except one, I am getting really crazy with it, because even Im cheking it manually I think is true, not false as is shown in the text .
palindrome("1 eye for of 1 eye.")
should return false.`
Here is my proposition, perhaps is not the best, but I feel proud to make it on my own.
function palindrome(str) {
var regChecker = /[^a-zA-Z]/g
var cleanText = ""
var lengthText = 0
var toCheck = "";
var valuePartA = ""
var valuePartB = ""
cleanText = str.replace( regChecker, '').toLowerCase()
console.log(cleanText.length)
lengthText = cleanText.length / 2
console.log(cleanText.length % 2)
if(cleanText.length % 2 != 0){
lengthText += 1
console.log(lengthText)
}
console.log(lengthText)
valuePartA = cleanText.slice(0, lengthText )
console.log(valuePartA)
valuePartB = cleanText.slice(lengthText * -1 ).split("").reverse().join("");
console.log(valuePartB)
if(valuePartA == valuePartB){
return true
}else{
return false
}
}
console.log(palindrome(“1 eye for of 1 eye.”));
Thank you everybody !! and keep coding