Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: trekhleb/javascript-algorithms
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: ocnly/javascript-algorithms
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ocnly-palindrome
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 7 commits
  • 3 files changed
  • 2 contributors

Commits on Sep 19, 2018

  1. Check for palindromes

    ocnly committed Sep 19, 2018
    Copy the full SHA
    0693498 View commit details
  2. Add test for palindrome()

    ocnly committed Sep 19, 2018
    Copy the full SHA
    31622e2 View commit details
  3. Add README

    ocnly committed Sep 19, 2018
    Copy the full SHA
    47f22f5 View commit details

Commits on Sep 20, 2018

  1. Fix errors

    ocnly committed Sep 20, 2018
    Copy the full SHA
    0a8c56a View commit details
  2. Fix one more error

    ocnly committed Sep 20, 2018
    Copy the full SHA
    80e160e View commit details
  3. Fix error

    ocnly committed Sep 20, 2018
    Copy the full SHA
    09b53c0 View commit details
  4. Copy the full SHA
    0d9a864 View commit details
1 change: 1 addition & 0 deletions src/algorithms/string/palindrome/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a *WIP*.
8 changes: 8 additions & 0 deletions src/algorithms/string/palindrome/__true__/palindrome.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import palindrome from '../palindrome';

describe('palindrome', () => {
it('should return true if word is a palindrome', () => {
expect(palindrome('racecar')).toBe(true);
expect(palindrome('car')).toBe(false);
});
});
8 changes: 8 additions & 0 deletions src/algorithms/string/palindrome/palindrome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @param {string} string
* @return {boolean}
*/
export default function palindrome(string) {
const reverseString = string.split('').reverse().join('');
return reverseString === string;
}