employer cover photo
employer logo
employer logo

Tata Consultancy Services

Part of Tata Group

Engaged Employer

Tata Consultancy Services Interview Question

In Coding Round, they asked about palindrome code

Interview Answer

Anonymous

Nov 8, 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