diff --git a/index.js b/index.js index ce2d431..8e4d54b 100644 --- a/index.js +++ b/index.js @@ -1,23 +1,12 @@ -function reverseString(word) { - // create an array from the input string - const wordArray = word.split(""); - // reverse the array - const reversedWordArray = wordArray.reverse(); - // create a string from the reversed array - const reversedWord = reversedWordArray.join(""); - // return the reversed string - return reversedWord; -} - function isPalindrome(word) { // reverse the input string const reversedWord = reverseString(word); - // if the reversed string is the same as the input - if (word === reversedWord) { - return true; - } else { - return false; - } + // compare the reversed string to the input + return word === reversedWord; +} + +function reverseString(word) { + return word.split("").reverse().join(""); } /*