Skip to content
Open
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
19 changes: 19 additions & 0 deletions Algorithms/Javascript/palindrome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//determines whether a word is a palindrome or not
const isPalindrome = function (word) {
let arr = [];

//loops through word in reverse, then pushes to array
for (let i = word.length - 1; i >= 0; i--) {
arr.push(word[i]);
}

// combines the arr
let newWord = arr.join("");

// compares word with newWord, if they match true is returned else false is returned
if (word == newWord) {
return true;
} else {
return false;
}
};