Skip to content

Commit

Permalink
Added temporary placeholder test
Browse files Browse the repository at this point in the history
  • Loading branch information
shirleyfyx committed Oct 14, 2023
1 parent 5b533d8 commit ccf4400
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions palindrome.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { isPalindrome } from './palindrome';

describe('isPalindrome', () => {
it('should return true for palindromic strings', () => {
expect(isPalindrome('radar')).toBe(true);
expect(isPalindrome('A man, a plan, a canal, Panama!')).toBe(true);
});

it('should return false for non-palindromic strings', () => {
expect(isPalindrome('hello')).toBe(false);
expect(isPalindrome('OpenAI')).toBe(false);
});
});
5 changes: 5 additions & 0 deletions palindrome.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const isPalindrome = (s: string): boolean => {
const cleanedString = s.replace(/[^A-Za-z0-9]/g, '').toLowerCase();
const reversedString = cleanedString.split('').reverse().join('');
return cleanedString === reversedString;
};

0 comments on commit ccf4400

Please sign in to comment.