challenges

Home / Palindrome

Palindrome

Write a function that determines if the first parameter is Palindrome or not.

What is a Palindrome?

Function Scaffolding

/**
 * Determines if the given string is a palindrome.
 * A palindrome reads the same forward and backward.
 *
 * @param {string} str - The string to check.
 * @returns {boolean} True if the string is a palindrome, false otherwise.
 */
function isPalindrome(str) {
    // ...
}

Possible Approach

  1. Create a function with one parameter. Have the function console.log() the input.
  2. Define an empty string variable called reverse to store the reversed string.
  3. Use a for loop to iterate through each character.
  4. Append each character to the beginning of the reverse variable.
  5. Return true if the contents of the input is the same as the reverse variable.

Assets

Download PDF Slide Desk