What is a palindrome?
If a string read the same from forward or backward. Example:- madam, dad, pop, radar, etc.
Built a javaScript project that can check your string whether palindrome or not?
Stack used:-
- HTML
- CSS
- JavaScript
GitHub
Live link
Explanation
Step1:
HTML code:- In this section, I put all necessary HTML code that helps you to design the front-end of the project.
Step2:
CSS code: In this section, you can design according to you, also you can copy my design too.
Step3:
After selecting the necessary element
- input filed
- button
Step4:
used addEventListener() click method to run a function i.e when the users click on the button the following program has been execute
split(' ')
The split method covert string into an individual array.
reverse()
The reverse method is used to reverse the position of an array element.
join(' ')
The join method is used to join all the elements of an array into a string.
Step5:
Used if statement to find, the string is palindrome or not, if input string and reversed string is equal then, the string is a palindrome. otherwise, it is not a palindrome.
Thank you.