Skip to content
Open
Changes from 1 commit
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
18 changes: 18 additions & 0 deletions November/Palidrome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// [November]/[Day 4]/[Javascript]/{Palidrome.js}
Comment thread
xxxSkypper marked this conversation as resolved.

/* Given a string, return true if the string is a palindrome or false if it is not. Palindromes are strings that form the same word if it is reversed. Do include spaces and punctuation in determining if the string is a palindrome. Make use of Functions and Methods where necessory */

function palidrome(str){
var len = str.length; // assign the length of string
var mid = Math.floor(len / 2); //round down

// checking the string
for (let i = 0; i < mid; i++){
if (str[i] !== str[len - 1 - i]) {
return false;
}
}
return true;
}

console.log(palidrome("abba")); // true