The Code
Code Structure
The code is structured into 3 functions that store the input from the user and run some code to determine if their input has the same value forwards as backwards.
The entry point:
function getValues()
Function 1:
The getValues
function takes the
value from the input, parses the data properly for use and uses that value
to go through a series of functions to check if the value is or is not a
palindrome.
Function 2:
The checkForPalindrome
function takes the normalized value from
getValues
and creates a copy of that string, reverses that string,
and then compare that reversed string to the normalized string to confirm it
is a palindrome. Once we have discovered if the input is the a palindrome that
information is returned back to getValues
.
Function 3:
The displayResults
function takes all the data we collect and uses
that data to create a message that will display seemlessly to the user. That
message is a javascript alert decorated using SweetAlert2
link.