Day 3: Palindrome in JavaScript – 3 Methods with Simple Explanations
🚀 Day 3 – Check if a String is a Palindrome (JavaScript DSA) Hey developers 👋, Welcome to Day 3 of my JavaScript + DSA Interview Series – Code With Jaffer. Today, we’re solving a super common and super important problem: > 🧠 Check if a given string is a palindrome. --- 🔍 What is a Palindrome? A palindrome is a word, phrase, number, or sequence that reads the same forward and backward. 🔤 Examples: ✅ "madam" → Palindrome ❌ "hello" → Not a palindrome ✅ "racecar" → Palindrome --- 💡 Problem Statement: Input: A string Output: true if it's a palindrome, else false --- ✅ Solution 1: Built-in JavaScript Functions function isPalindrome(str) { return str === str.split('').reverse().join(''); } 🧠 Explanation: split(''): Converts string to array reverse(): Reverses array join(''): Combines back into a string Compares reversed and original 💬 Tips to Remember: > Split → Reverse → Join → Compare Use this when you need a...