Working function

This commit is contained in:
billalp 2019-11-01 12:33:00 +00:00
parent 6c3a7496be
commit c7d61f82e9
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