These are chat archives for FreeCodeCamp/PairProgrammingWomen

17th
Jan 2016
Jessica Burns
@Astayonix
Jan 17 2016 01:53
Would anyone like to do a livepair on the palindrome bonfire?
Eina
@thelittleblacksmith
Jan 17 2016 01:59
@Astayonix I've already done that one, sorry!
Jessica Burns
@Astayonix
Jan 17 2016 02:00
NP! :)
Eina
@thelittleblacksmith
Jan 17 2016 02:04
@Astayonix also, I saw your code on the regular help chat, you don't have to take out the numbers, just the special characters
Jessica Burns
@Astayonix
Jan 17 2016 02:07
Ooooh...
@thelittleblacksmith Thank you!
CamperBot
@camperbot
Jan 17 2016 02:07
astayonix sends brownie points to @thelittleblacksmith :sparkles: :thumbsup: :sparkles:
:star: 300 | @thelittleblacksmith | http://www.freecodecamp.com/thelittleblacksmith
Eina
@thelittleblacksmith
Jan 17 2016 02:08
@Astayonix yeah, that;s why the last test returns true because it's just all 0's :)
Jessica Burns
@Astayonix
Jan 17 2016 02:09
LOL! I thought I was supposed to get rid of anything that wasn't A-Z, a-z ; Silly me!
Jessica Burns
@Astayonix
Jan 17 2016 02:28
My code now passes every test except "almostomla". I'm not sure why.
Jessica Burns
@Astayonix
Jan 17 2016 02:49

`var myString = "almostomla";
var myArray = [];
var regexPattern = /\W+|_+/gi; //get rid of all non-word chars (spaces and special chars), and all underscores (global, ignore case)
var myLowerString = myString.toLowerCase();
var myCleanString = myLowerString.replace(regexPattern, "");

for (var letter in myCleanString) {
myArray.push(myCleanString[letter]);
}

if (myArray.length % 2 !== 0) { //addresses all arrays with an even length
for (var i = 0; myArray.length > 2; i--) { //iterates through a decreasing number of loops
if (myArray[0] === myArray[myArray.length-1]) { //checks to see if the [0] and [-1] position of the array are the same
console.log(myArray + "This IS a palindrome");
myArray.pop(); //remove the [-1]th item in the array
myArray.shift(); //remove the [0]th item in the array
}
else {
console.log (myArray + "This IS NOT a palindrome.");
break;
}
}
}
else {
for (var i = 0; myArray.length > 1; i--) {
if (myArray[0] === myArray[myArray.length-1]) {
console.log(myArray + "This IS a palindrome");
myArray.pop();
myArray.shift();
}
else {
console.log (myArray + "This IS NOT a palindrome.");
break;
}
}
}

consoe.log(myArray)`

The result is: a,l,m,o,s,t,o,m,l,aThis IS a palindrome
l,m,o,s,t,o,m,lThis IS a palindrome
m,o,s,t,o,mThis IS a palindrome
o,s,t,oThis IS a palindrome
s,tThis IS NOT a palindrome."
So, it should be failing, but for some reason it's not. :worried: in the automated tests for FCC
Eina
@thelittleblacksmith
Jan 17 2016 02:54
@Astayonix sorry I was afk for a bit there, have you figured it out yet?
Jessica Burns
@Astayonix
Jan 17 2016 02:56
@thelittleblacksmith No worries! :) Not quite yet. It fails on a console log, but doesn't fail on the FCC automated test.
Eina
@thelittleblacksmith
Jan 17 2016 02:57
@Astayonix .reverse() works wonders for this bonfire btw :D
Jessica Burns
@Astayonix
Jan 17 2016 02:58
I know it does :). However, in a lot of tech interviews, you're asked to reverse a string without using the .reverse method, and I wanted to make sure I could do that.
:P
Eina
@thelittleblacksmith
Jan 17 2016 03:00
Ahh fair enough, you had a typo btw at the very last console there
Jessica Burns
@Astayonix
Jan 17 2016 03:04
Yeah, I was trying to get the code view working properly, but failed :-1:
Imagine that console.log line without the ` at the end.