Find if string is a palindrome?
Steps:
- Loop through the characters in the string
- Check if the first letter match the last letter
- Check second letter match the second to last letter
function palindrome(str) {
for(let i = 0; str.length - i > i; i++) {
if (str[i] !== str[str.length - 1 - i]) {
return false;
}
}
return true;
}
palindrome('madam')