function isPalindrome(x) { const xReverse = x.split("").reverse().join(""); return !!(xReverse.toLowerCase() === x.toLowerCase()) }
function Palindrome(s) {let a=-1, z=s.length;while(++a < --z)if(s[a] != s[z])return false;return true;- function isPalindrome(x) {
- const xReverse = x.split("").reverse().join("");
- return !!(xReverse.toLowerCase() === x.toLowerCase())
- }
describe("Solution", function () { it('racecar', function () { Test.assertEquals(isPalindrome('racecar'), true); }); it('radar', function () { Test.assertEquals(isPalindrome('radar'), true); }); it('peep', function () { Test.assertEquals(isPalindrome('peep'), true); }); it('nitin', function () { Test.assertEquals(isPalindrome('nitin'), true); }); it('civic', function () { Test.assertEquals(isPalindrome('civic'), true); }); it('276672', function () { Test.assertEquals(isPalindrome('276672'), true); }); it('19791', function () { Test.assertEquals(isPalindrome('19791'), true); }); it('spencer', function () { Test.assertEquals(isPalindrome('spencer'), false); }); it('Radar', function () { Test.assertEquals(isPalindrome('Radar'), true); // case-sensitivity? }); it('Radar', function () { Test.assertEquals(isPalindrome('Madam'), true); // case-sensitivity? }); it('X', function () { Test.assertEquals(isPalindrome('X'), true); // singleton? }); it('(empty string)', function () { Test.assertEquals(isPalindrome(''), true); // empty string? }); it('TACOCAT', function () { Test.assertEquals(isPalindrome('TACOCAT'), true); // TACOCAT! }); it('garbage', function () { Test.assertEquals(isPalindrome('garbage'), false); // garbage. }); });
describe("Solution", function () {it('racecar', function () {Test.assertEquals(Palindrome('racecar'), true);});it('radar', function () {Test.assertEquals(Palindrome('radar'), true);});it('peep', function () {Test.assertEquals(Palindrome('peep'), true);});it('nitin', function () {Test.assertEquals(Palindrome('nitin'), true);});it('civic', function () {Test.assertEquals(Palindrome('civic'), true);});it('276672', function () {Test.assertEquals(Palindrome('276672'), true);});it('19791', function () {Test.assertEquals(Palindrome('19791'), true);});it('spencer', function () {Test.assertEquals(Palindrome('spencer'), false);});it('Radar', function () {Test.assertEquals(Palindrome('Radar'), false); // case-sensitivity?});it('X', function () {Test.assertEquals(Palindrome('X'), true); // singleton?});it('(empty string)', function () {Test.assertEquals(Palindrome(''), true); // empty string?});it('TACOCAT', function () {Test.assertEquals(Palindrome('TACOCAT'), true); // TACOCAT!});it('garbage', function () {Test.assertEquals(Palindrome('garbage'), false); // garbage.});- describe("Solution", function () {
- it('racecar', function () {
- Test.assertEquals(isPalindrome('racecar'), true);
- });
- it('radar', function () {
- Test.assertEquals(isPalindrome('radar'), true);
- });
- it('peep', function () {
- Test.assertEquals(isPalindrome('peep'), true);
- });
- it('nitin', function () {
- Test.assertEquals(isPalindrome('nitin'), true);
- });
- it('civic', function () {
- Test.assertEquals(isPalindrome('civic'), true);
- });
- it('276672', function () {
- Test.assertEquals(isPalindrome('276672'), true);
- });
- it('19791', function () {
- Test.assertEquals(isPalindrome('19791'), true);
- });
- it('spencer', function () {
- Test.assertEquals(isPalindrome('spencer'), false);
- });
- it('Radar', function () {
- Test.assertEquals(isPalindrome('Radar'), true); // case-sensitivity?
- });
- it('Radar', function () {
- Test.assertEquals(isPalindrome('Madam'), true); // case-sensitivity?
- });
- it('X', function () {
- Test.assertEquals(isPalindrome('X'), true); // singleton?
- });
- it('(empty string)', function () {
- Test.assertEquals(isPalindrome(''), true); // empty string?
- });
- it('TACOCAT', function () {
- Test.assertEquals(isPalindrome('TACOCAT'), true); // TACOCAT!
- });
- it('garbage', function () {
- Test.assertEquals(isPalindrome('garbage'), false); // garbage.
- });
- });