836
In this example we check if a string is a palindrome in python
A palindrome is a string that is the same read forward or backward.
Example
// check if a string is palindrome or not function checkPalindrome(string) { // convert string to an array const arrayValues = string.split(''); // reverse the array const reversedArray = arrayValues.reverse(); // convert array to string const reversedString = reversedArray.join(''); //check both strings if(string == reversedString) { console.log('It is a palindrome'); } else { console.log('It is not a palindrome'); } } //get input const string = prompt('Enter a string: '); checkPalindrome(string);
When you run this you will see something like this
It is a palindrome