Skip to content

WeekOneHomework *completed* #9

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

array415
Copy link

@array415 array415 commented Jul 1, 2016

Was fun.
WDI30 homework group is 10/10!

my comfort level was 3

@melicarls
Copy link
Contributor

Your solutions are great! I'm glad that you were able to work with your peers- that's an awesome way to practice and learn. A quick note on isPalindrome:

  • Here's a suggestion to get rid of spaces and handle capitalization:
var shiftedLetter;
var poppedLetter;
var wordArray; 

function shiftAndPop() {
  shiftedLetter = wordArray.shift();
  poppedLetter = wordArray.pop();
}

function isPalindrome(word) {
// This line will split the word (or sentence) at each space and join it back together without the spaces
// Then it converts the word into lowercase so the function overlooks capitalization
  word = word.split(' ').join('').toLowerCase()
  wordArray = word.split("");
  shiftAndPop();

  while(shiftedLetter === poppedLetter){
    shiftAndPop();

  if(wordArray <= 1) {
    return true;
  }

  }
    return false;
}

It's generally not a great idea to use global variables. If you can refactor this solution to declare your variables within the functions, that would be considered a more DRY solution.

@melicarls melicarls closed this Jul 6, 2016
@melicarls melicarls reopened this Jul 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants