Merge pull request #4 from BillalPatel/palindrome

Working function
This commit is contained in:
Billal Patel 2019-11-01 12:33:52 +00:00 committed by GitHub
commit 68eebc9015
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -1,5 +1,17 @@
const palindromes = function() { const palindromes = function(word) {
const wordArr = word.split('');
const reversedArray = wordArr.reverse();
newArray = [];
for (var i = 0; i < wordArr.length; i++) {
if (wordArr[i] === reversedArray[i]) {
newArray.push(wordArr[i])
} else {
newArray = ['Not a palindrome'];
}
}
return true ? newArray.join('') === word : false;
} }
module.exports = palindromes module.exports = palindromes