Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions solutions/13.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
//Rahul Kalra
//Checking to see if the string is palindrome
const solution2 = (palindromeInput) =>{
let reverse = "";
for(let i = palindromeInput.length - 1; i >= 0; i--){
reverse += palindromeInput[i];
}
if(reverse === palindromeInput){
return true;
}
return false;
};

// vdewinter
// Return true if input string is a palindrome

Expand All @@ -15,4 +28,6 @@ const solution = (str) => {

module.exports = {
solution,
solution2
};

11 changes: 6 additions & 5 deletions test/13.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const expect = require('chai').expect;
let solution = require('../solutions/13').solution;
// solution = require('./yourSolution').solution;

solution2 = require('../solutions/13').solution2;
describe('reverse String', () => {
it('should return true if input string is a palindrome', () => {
expect(solution('racecar')).to.equal(true);
expect(solution("racecar")).to.equal(true);
expect(solution2("racecar")).to.equal(true);
});
it('should return true if input string is a palindrome', () => {
expect(solution('palindrome')).to.equal(false);
});
expect(solution("palindrome")).to.equal(false);
expect(solution2("palindrome")).to.equal(false);
});
});