cpt-waffle-lotide
Version:
LoTide in Typescript
13 lines (11 loc) • 413 B
text/typescript
// FUNCTION IMPLEMENTATION (MULTIPLE BUGS)
const isPalindrome = (str:string):boolean => {
const noSpaces:string = str.toLowerCase().split(" ").join("");
const midIndex:number = Math.floor(noSpaces.length/2);
const lastIndex:number = noSpaces.length - 1;
for (let i = 0; i < midIndex; i++) {
if (noSpaces[i] !== noSpaces[lastIndex - i]) return false;
}
return true;
}
export default isPalindrome;