CODE EXPLAINED STEP BY STEP
First we create a variable called cadena. In this variable we store what the user enters using a prompt pop up.
Since we do not know if the user will enter uppercase or lowercase letters, we apply the toLowerCase ( ) method . This method converts the entered text to lowercase letters, in case uppercase letters are entered. Thus, text comparison is easier and we avoid possible “case sensitive” errors of letters or names.
With the replace ( ) method , we remove the empty spaces that the text may have after the user has entered his request.
Then we create another variable called reves. This variable converts the information of the user from right to left the value stored in cadena and this way the two variables can be compared to each other.
Finally this comparision is carried out by the function palindromo, as it collects the value of cadena and it compares it with the value of reves. If the information entered matches with each other, we will get a succesful message or alternatively an unseccesful message.