Skip to content

Instantly share code, notes, and snippets.

@joefearnley
Created June 29, 2020 14:10
Show Gist options
  • Save joefearnley/9f06cc7ff602e441b95461baf90b4cf8 to your computer and use it in GitHub Desktop.
Save joefearnley/9f06cc7ff602e441b95461baf90b4cf8 to your computer and use it in GitHub Desktop.
The 10-Day JS Challenge - Day 5: Case Insensitive Palindrome
const caseInsensitivePalindrome = str => str.toLowerCase() === str.split('').reverse().join('').toLowerCase();
describe('caseInsensitivePalindrome()', () => {
it('returns true for a case insensitive palindrome', () => {
// arrange
const str = 'AaBaa';
// act
const result = caseInsensitivePalindrome(str);
// log
console.log("result 1: ", result);
// assert
expect(result).toBe(true);
});
it('returns false when not a case insensitive palindrome', () => {
// arrange
const str = 'abac';
// act
const result = caseInsensitivePalindrome(str);
// log
console.log("result 2: ", result);
// assert
expect(result).toBe(false);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment