employer cover photo
employer logo
employer logo

Tata Consultancy Services

Fait partie de Tata Group

Employeur impliqué

Question d’entretien chez Tata Consultancy Services

In Coding Round, they asked about palindrome code

Réponse à la question d'entretien

Utilisateur anonyme

8 nov. 2024

function isPalindrome(str) { for (let i = 0; i < str.length / 2; i++) { if (str[i] !== str[str.length - 1 - i]) { return false; // If characters don't match, it's not a palindrome } } return true; // If all characters match, it's a palindrome } console.log(isPalindrome("racecar")); // Output: true console.log(isPalindrome("hello")); // Output: false