Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Palidrome #28

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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}
xxxSkypper marked this conversation as resolved.
Show resolved Hide 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