Working function
This commit is contained in:
parent
6c3a7496be
commit
c7d61f82e9
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue