const isPalindrome = (str) => {
  return str
    .toString()
    .split("")
    .reverse()
    .join("") === str.toString();
};

describe("isPalindrome", () => {
  it("returns true if the string is a palindrome", () => {
    expect(isPalindrome("abba")).toEqual(true);
  });
  it("returns false if the string isn't a palindrome", () => { 
    expect(isPalindrome("Bubba")).toEqual(false);
  });
  it("returns true if a number is a palindrome", () => {
    expect(isPalindrome(1001)).toEqual(true);
  });
});
Run Pen

External CSS

  1. https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.6.1/jasmine.min.css

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.6.1/jasmine.min.js
  2. https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.6.1/jasmine-html.min.js
  3. https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.6.1/boot.min.js