These are chat archives for FreeCodeCamp/Help

23rd
Jun 2015
Lightwaves
@Lightwaves
Jun 23 2015 00:00
yeah it is I'm currently going through the javascript examples now.
haha VB.net? or we talking VB6?
Adam Rehard
@adamrehard
Jun 23 2015 00:04
VB.NET. Programming101 at my school is in VB. Thier upper level DB course is in Access of all things.
It wasnt that bad, but I came in with a bit of Python experience. VB is nasty
Steven Walters
@StevenKW
Jun 23 2015 00:26

Hello any thoughts on making this work? Title Case a Sentence Bonfire

function titleCase(str) {
    str = str.toLowerCase();
    str = str.replace(/\b\w/g, function(match) {return match.toUpperCase();});
    console.log(str);
    return str;
}

titleCase(“I’m a little tea pot");

It works except for the i’m the puntuation is causing the \b to match.

Michael Krebs
@michael-krebs
Jun 23 2015 00:44
@StevenKW I don't think you can use \b there then, might have to take another approach
Steven Walters
@StevenKW
Jun 23 2015 00:46
except it works so nice if there isn’t any punctuation :) no array, no loop, I was so happy for a second ha ha
Lightwaves
@Lightwaves
Jun 23 2015 00:46
so titleCase is im a tea pot becomes Im A Tea Pot
Steven Walters
@StevenKW
Jun 23 2015 00:47
Im getting “I’M A Little…” the \b hits the ‘ as a word boundary
Michael Krebs
@michael-krebs
Jun 23 2015 00:47
@StevenKW I did it with no loops and regex. It also uses .substr()
Lightwaves
@Lightwaves
Jun 23 2015 00:48
I can think of a way screw it I might just try it now
Steven Walters
@StevenKW
Jun 23 2015 00:48
ha ha
Lightwaves
@Lightwaves
Jun 23 2015 00:48
I'd be super excited if it works
lol I'm still going through the javascript way points
Because I want to be prim and proper :P
that and I'm not familiar with javascript syntax at all
Steven Walters
@StevenKW
Jun 23 2015 00:51
for example TitleCase(“HERE IS MY HANDLE HERE IS MY SPOUT”) works great.
Moisés Man
@moigithub
Jun 23 2015 00:54
any1 doin zipline twitchtv ?
split map join works too
Lightwaves
@Lightwaves
Jun 23 2015 01:03
That's what I was trying to do.
I figured it'd work can't get the syntax right
split into an array map toUppercase to each then join to create a string
Moisés Man
@moigithub
Jun 23 2015 01:04
yes
Lightwaves
@Lightwaves
Jun 23 2015 01:04
"lol goes back to javascript waypoints with head down"
ar2g
@ar2g
Jun 23 2015 01:05
is there an official answer to http://www.freecodecamp.com/challenges/bonfire-make-a-person kicking around? I completed it but want to be clear about what the question was demonstrating.
Jonathan
@jonathantimm
Jun 23 2015 01:07
Anybody see a problem with this code?
$(document).ready(function() {
    $(document).keydown() {
        $('div').animate({left:'+=10px'},500);
    });
});
Code Academy says I did it right, but I'm not seeing the animation.
Moisés Man
@moigithub
Jun 23 2015 01:08
r u pressin keys ?? inside ur webpage ?
Jonathan
@jonathantimm
Jun 23 2015 01:09
@moigithub yup
John Ellis
@johnmellis
Jun 23 2015 01:10
@terakilobyte You online?
ar2g
@ar2g
Jun 23 2015 01:11
@jonathantimm does it work on jsfiddle?
Lightwaves
@Lightwaves
Jun 23 2015 01:11
Got it
Moisés Man
@moigithub
Jun 23 2015 01:11
what.. if.. put console.log("aaa"); inside keydown,, n check on devtools if its working ?
Lightwaves
@Lightwaves
Jun 23 2015 01:11
Now I go back to javascript waypoints with my head up
lol
still looks fugly though
and hacky
wonder if there is a more elegant way of doing it
ar2g
@ar2g
Jun 23 2015 01:12
@Lightwaves post your code, let's have a butchers
Jonathan
@jonathantimm
Jun 23 2015 01:13
@ar2g good question, lemme check
Lightwaves
@Lightwaves
Jun 23 2015 01:13
function titleCase(str) {
  var textArray = str.toLowerCase().split(" ");
  textArray = textArray.map(function(x){return x.charAt(0).toUpperCase()+x.substring(1);});
  return textArray.join(" ");
}
Jonathan
@jonathantimm
Jun 23 2015 01:15
@ar2g it doesn't
ar2g
@ar2g
Jun 23 2015 01:15
@Lightwaves it's nice - but maybe you don't need textArray?
@jonathantimm bother. it looks alright but it's been a while since I looked at jQuery
Lightwaves
@Lightwaves
Jun 23 2015 01:16
it felt way to messy if I just chained toLowercase split map
ar2g
@ar2g
Jun 23 2015 01:17
@Lightwaves style pref I guess
Lightwaves
@Lightwaves
Jun 23 2015 01:18
I mean chaining everything it's a one liner but it's kinda an ugly one liner to look at lol
maybe it's just me
ty for the comments @ar2g
and for taking a look
Jonathan
@jonathantimm
Jun 23 2015 01:19
@ar2g thanks anyway. I can just move on - I know it's right, no need to harp on that one exercise now
ar2g
@ar2g
Jun 23 2015 01:19
@Lightwaves I think the convention is to line break at each link of the chain. No worries at all - it's a nice solution (mine was a dog's breakfast in comparison)
Jonathan
@jonathantimm
Jun 23 2015 01:20
@ar2g code academy is very finicky. There were so many exercises where I had to refresh to get it to accept my code, or other stuf
ar2g
@ar2g
Jun 23 2015 01:20
@jonathantimm yeah I found it a right pain
not much on recursion in these bonfire probs
Lightwaves
@Lightwaves
Jun 23 2015 01:26
the factorial bonfire can actually be solved with recursion pretty easily
unless in the unit test they purposely put in a large factorial to see if it overflows the stack xD
ar2g
@ar2g
Jun 23 2015 01:27
yeah and there's a fibonacci question too... but not much else
Tom DeFrank
@TomDeFrank
Jun 23 2015 01:27
yeah recursion works
ar2g
@ar2g
Jun 23 2015 01:27
ha checking for stack overflow - that's what I call testing
Steven Leiva
@StevenXL
Jun 23 2015 01:29
wow
things get much more difficult in the ziplines
ar2g
@ar2g
Jun 23 2015 01:30
yup...
have you finished the advanced algos @StevenXL ?
Steven Leiva
@StevenXL
Jun 23 2015 01:31
@ar2g I've only finished 3 out of the 6.
My goal is to complete 1 Advanced Algo every day
I wanted to check out the ziplines just to get a taste of what was coming.
@ar2g have you done any of the ziplines?
ar2g
@ar2g
Jun 23 2015 01:36
I'm just starting the adv algos and having a peek like you! @StevenXL
Steven Leiva
@StevenXL
Jun 23 2015 01:36
haha
Awesome. Maybe we can pair on the ziplines since we don't seem to be too far apart.
ar2g
@ar2g
Jun 23 2015 01:37
great idea @StevenXL - this weekend?
Steven Leiva
@StevenXL
Jun 23 2015 01:38
Sure!
ar2g
@ar2g
Jun 23 2015 01:41
Awesome!
Nathan
@terakilobyte
Jun 23 2015 01:53
@johnmellis I am now
was watching the Colombians eat their words
Moisés Man
@moigithub
Jun 23 2015 01:58
just finished twitchTV zipline.. but the functionality doesnt look like the example,,, when show the data.. on the example.. it instant pop, on mine looks like it flickering... http://codepen.io/MMan/full/VLMoGB
Miguel Correa
@miguelc1221
Jun 23 2015 01:58
was wondering if someone can help me on why my program is not working
function Palindrome(str) { 
    var splitStr = str.split("");
      var newStr = [];

  for (var i = 0; i < splitStr.length; i++) {
      if ( splitStr[i].length > 0 ) {
        newStr.push(splitStr[i]);
    }
  }

  if (str === newStr.reverse().join("")){
      return true;
  } else {
      return false;
  }
}
Palindrome(“never odd or even”) returns false instead of true
Moisés Man
@moigithub
Jun 23 2015 02:00
..probably i need to collect data first.. and after get all..... show it, im doin collect+show on json.done callbakc
Nathan
@terakilobyte
Jun 23 2015 02:00
could you edit that to format it on new lines?
Moisés Man
@moigithub
Jun 23 2015 02:03
@miguelc1221 u need to clean the string first.... like spaces
Miguel Correa
@miguelc1221
Jun 23 2015 02:04
@moigithub but thats what i did it the for loop
Moisés Man
@moigithub
Jun 23 2015 02:04
nope :)
" " <- empty string.. = length 1
Miguel Correa
@miguelc1221
Jun 23 2015 02:05
if the length of the splitStr[i] is greater than 0, i push it to a new array, and it won’t push a “ “ because its length is not greater than 0
Moisés Man
@moigithub
Jun 23 2015 02:05
u can test on console.. (control shift i ) and type " ".length
Miguel Correa
@miguelc1221
Jun 23 2015 02:05
aaa when i tested it i used “” instead of “ "
jesus christ i been going crazy because of that
so that wouldn’t work hmm
Moisés Man
@moigithub
Jun 23 2015 02:07
u can use replace + regex
Miguel Correa
@miguelc1221
Jun 23 2015 02:07
yea i am trying to do it without regex
Moisés Man
@moigithub
Jun 23 2015 02:07
instead for/loop
u can use indexOf..
in ur forloop
like.. var unwantedchars = " .,-!·$%&/()=";
for ...
if unwantedchars.indexOf( splitstr[i]) >-1
// found unwanted char.. SKIP it !
else add it
Miguel Correa
@miguelc1221
Jun 23 2015 02:11
@moigithub how come this didn’t work ?
if ( splitStr[i] !== " " ) {
newStr.push(splitStr[i]);
}
Nathan
@terakilobyte
Jun 23 2015 02:16
splitStr will still have the space
at the moment you are essentially comparing apples to oranges
you need to do the same validation to both strings before you compare them
Miguel Correa
@miguelc1221
Jun 23 2015 02:17
yea i see it now
Nathan
@terakilobyte
Jun 23 2015 02:18
incidentally, this is where regex is incredibly useful
you might want to look at String.prototype.replace on the mdn
Steven Leiva
@StevenXL
Jun 23 2015 02:26
Crap. I named my branch stevenxl-1070 and it's actually issue 1071
:-(
wait - that's my mistake. It looks like 1071 was created when I issued the pull request.
Nathan
@terakilobyte
Jun 23 2015 02:33
closed PR, next time specify the file in the pr message plz
"Fixes chat links in README to point to gitter" or something
Don
@raydancer
Jun 23 2015 02:41
I just finished the "Reference your Current Object with This" Waypoint and can't seem to get to the next one...is the FCC site down?
Miguel Correa
@miguelc1221
Jun 23 2015 02:52
@terakilobyte well i tried doing without regex and my head hurts lol
@terakilobyte the first time i did it, i used
function palindrome(str) {
str = str.replace(/[^a-zA-Z]/g, '').toLowerCase();
reverseString = str.split("").reverse().join("");
  if (str === reverseString){
    return true;
  } else {
    return false;
  }
  return true;
}
Steven Leiva
@StevenXL
Jun 23 2015 02:52
@terakilobyte you got it.
It will be more explicit next time.
Nathan
@terakilobyte
Jun 23 2015 02:56
@miguelc1221 now one more thing
why not just return the direct result of the evaluation?
meaning return str === reverseString
Miguel Correa
@miguelc1221
Jun 23 2015 02:57
oh
Nathan
@terakilobyte
Jun 23 2015 02:57
remember that when the language encounters that, it says "oh here's a boolean comparison, let me compare it and sub in the result"
Miguel Correa
@miguelc1221
Jun 23 2015 02:57
thats right
Nathan
@terakilobyte
Jun 23 2015 02:57
you'll see it a lot as you progress
:)
Tom DeFrank
@TomDeFrank
Jun 23 2015 02:59
wish i would have known that reverse() method existed
heh
This message was deleted
This message was deleted
for(var letter in str){
            strlist.unshift(str[letter]);
    }
there we go :)
Miguel Correa
@miguelc1221
Jun 23 2015 03:03
@terakilobyte is it just me or once you go through the functional waypoint, the beginning challenges become much easier with those methods
lol
Nathan
@terakilobyte
Jun 23 2015 03:03
that's how it's supposed to be ;)
on purpose
we really think the future is in functional style programming
the battle with imperative that a lot of people have, then they get introduced to functional style and they go "well damn, that was easy when I didn't have to worry about x or y"
Cristián Berríos
@crisberrios
Jun 23 2015 03:07
someone said functional?
John Ellis
@johnmellis
Jun 23 2015 03:10
I would totally agree
Miguel Correa
@miguelc1221
Jun 23 2015 03:12
the only thing i don’t understand is why is it called functional programming? isnt JS oop and aren’t those methods part of js. To me they are just different methods….
BL Hill
@montythemack
Jun 23 2015 03:19
Any idea what I am doing wrong here with the Bonfire: Make A Person?
var Person = function(firstAndLast) {
  this.getFullName = function(){
      return firstAndLast;
    };
  this.setFirstName = function(str){
    this.firstName = str;
  };
  this.setLastName = function(str){
    this.lastName = str;
  };
  this.setFullName = function(str){
    this.firstAndLast = str;
  };
  this.getFirstName = function(){
    var arr= [];
    arr = firstAndLast.split(' ');
    return arr[0];
  };
  this.getLastName = function(){
    var arr= [];
    arr = firstAndLast.split(' ');
    return arr[1];
  };

};

var bob = new Person('Bob Ross');
bob.getFullName();
Any help?
Greg Haas
@izzaboo
Jun 23 2015 03:22
I'm working on Sorted Union bonfire. Does it seem like the solution excludes the earlier "duplicate" elements? In my mind, the final array should exclude the later duplicates. I wonder what I'm missing...
They're wanting [ 1, 3, 2, 5, 4 ] but I want [ 1, 2, 3, 5, 4 ]. I must be misunderstanding the instructions. Any pointers?
BL Hill
@montythemack
Jun 23 2015 03:24
@izzaboo concatenate them all into one array and then create a new array where you push the values into where they don't already match what is in the new array
Greg Haas
@izzaboo
Jun 23 2015 03:26
@montythemack thanks. that's kinda what I'm trying. I don't think I'm all the way there yet. What errors are you getting on your Person script?
BL Hill
@montythemack
Jun 23 2015 03:26
in other words. Whatever values are in the old array should not be in the new array. Try using indexOf()
@izzaboo It is passing all of the tests except for the 3 near the bottom excluding the last one. I don't know whats up.
Greg Haas
@izzaboo
Jun 23 2015 03:32
@montythemack afraid I'm not much help on person script. (does there need to be 'return' before bob.getFullName()?)
Cristián Berríos
@crisberrios
Jun 23 2015 03:33
@miguelc1221 functional programming is all about having deterministic functions. Input .... Output. No side effects. It paves the way for reusability, testability and composability.
At some point you DO need side effects, but that should be only at the endpoint. The rest aims to only depend on what you put into it, not being aware of the surroundings like functions you trigger and then read from the DOM using jQuery, for example.
Sam Rich
@samrichca
Jun 23 2015 03:39
can anyone help with a bonfire issue? i've been picking away at this for a couple days

``` function mutation(arr) {
var str1 = arr[0].toLowerCase().split('').sort();
var str2 = arr1.toLowerCase().split('').sort();
var i = 0;
var j = 0;
var indices = [];
var idx = str1.indexOf(str2[i]);

for(i; i < str2.length; i++) {
indices.push(idx);
return idx;
}
return indices;

/if(indices.indexOf(-1) > -1) {
// -1 means the value wasn't found in the array
// if the array contains a -1 that means
// one of the letters didn't match
return true;
} else {
return false;
}
/

}

mutation(['hello', 'hello']);
```

arr1 does have brackets in my code, that's strange
Timothy Touch
@timtouch
Jun 23 2015 03:42
@montythemack I think you are not actually changing the first or last name when you use setFirstName/LastName()
BL Hill
@montythemack
Jun 23 2015 03:48
why not? @timtouch
Timothy Touch
@timtouch
Jun 23 2015 03:50
Because you are storing the value in a variable called firstName or lastName but not actually updating the value of firstAndLast
BL Hill
@montythemack
Jun 23 2015 03:54
Okay fixed that @timtouch. Only have one test failing now. Any idea why my getFullName function is returning undefined?
Timothy Touch
@timtouch
Jun 23 2015 03:55
Mind showing what it looks like now?
BL Hill
@montythemack
Jun 23 2015 03:56
var Person = function(firstAndLast) {
  this.getFullName = function(){
      return firstAndLast;
    };
  this.setFirstName = function(str){
    firstAndLast = str;
  };
  this.setLastName = function(str){
    firstAndLast = str;
  };
  this.setFullName = function(str){
    firstAndLast = str;
  };
  this.getFirstName = function(){
    var arr= [];
    arr = firstAndLast.split(' ');
    return arr[0];
  };
  this.getLastName = function(){
    var arr= [];
    arr = firstAndLast.split(' ');
    return arr[1];
  };

};

var bob = new Person('Bob Ross');
bob.getFullName();
@timtouch
Greg Haas
@izzaboo
Jun 23 2015 04:01
@montythemack You don't need to pass firstAndLast into this.getFullName?
like you passed str into the set? sincere question (I'm still coming to terms with scope of variables)
BL Hill
@montythemack
Jun 23 2015 04:02
Didn't need to on the other Get methods
Sam Rich
@samrichca
Jun 23 2015 04:02
nevermind about my question. I found a solution online.
Timothy Touch
@timtouch
Jun 23 2015 04:02
@montythemack It looks like now when you setFirstName or setLastName(), you change the whole name to either the new first name or last name.
Alyssa Alvarez
@AlysCole
Jun 23 2015 04:03
@montythemack For this.setFirstName, you should set firstAndLast = firstAndLast.split(" ")[0] = str;
BL Hill
@montythemack
Jun 23 2015 04:03
but it doesn't explain why I'm getting undefined for getFullName @timtouch. Wouldn't I get either the first or last name?
Timothy Touch
@timtouch
Jun 23 2015 04:04
Ah, because when you split it, and it only has a last name, the array size is only 1
Alyssa Alvarez
@AlysCole
Jun 23 2015 04:05
@montythemack Or something like that actually. probably set a new variable, as the code I gave doesn't work.
Timothy Touch
@timtouch
Jun 23 2015 04:05
So you try to access a part of the array that is not there and it returns undefined
BL Hill
@montythemack
Jun 23 2015 04:06
i see now @timtouch
got it! thanks @timtouch
Timothy Touch
@timtouch
Jun 23 2015 04:09
@montythemack Glad I could help you .:]
Lightwaves
@Lightwaves
Jun 23 2015 04:50
Anyone mind looking over my second bonfire.
it passes just want to see how someone else may have did it
Check for Palindromes
Justin Chi
@vai0
Jun 23 2015 07:08
anyone finish the Bonfire: Inventory Update?
I'm wondering how to approach this with functional programming
can anyone help with how to approach this problem, the pseudocode?
tjstinso
@tjstinso
Jun 23 2015 07:33
I think you could do something like arr1.map(function( {
arr2.forEach({ //add values already present in array });
} ).forEach(function({ arr2.some(function({ //add extra values not present}) )};
Justin Chi
@vai0
Jun 23 2015 07:43
hm..
i don't quite get the second forEach you did there
passing a function into a function in the forEach method
Paweł
@ridlez
Jun 23 2015 09:33
Hey, could somebody help me with "Your div element should have a gray background."? I am trying and trying and can't move on
jgadjiev
@jgadjiev
Jun 23 2015 09:34
can you show me your code?
Paweł
@ridlez
Jun 23 2015 09:34
<div class='gray-background' <style>
.gray-background { background-color: gray; }
</style>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>

</div>
Krzysztof Miąsko
@kmiasko
Jun 23 2015 09:35
your <style> should be inside <head></head> tag
not in <div .. >
Paweł
@ridlez
Jun 23 2015 09:41
nope doesnt work
i didnt have <head> tag yet
Jakob Dahl
@saadanerdetbare
Jun 23 2015 09:50
then the style should go inside the <div> tag
like so <div style="color:blabla"></div>
Maria
@MariaVisee
Jun 23 2015 09:51
<div class='gray-background' you're missing your closing >
Paweł
@ridlez
Jun 23 2015 09:52
thank you guys
Moisés Man
@moigithub
Jun 23 2015 13:37
any1 know a place to copy/extract Quotes?
Nathan
@terakilobyte
Jun 23 2015 13:38
This is a quote
precede the sentence with a >
Moisés Man
@moigithub
Jun 23 2015 13:40
www
Nathan
@terakilobyte
Jun 23 2015 13:57
.quote.com
Jeremiah Biard
@jeremiahbiard
Jun 23 2015 14:26
Oppa Gangnam Style
Edgar S. Hurtado
@edgarshurtado
Jun 23 2015 14:36
I have a question

‘’’javascript
function extractExtraArguments(args){
var resultArray = [];
for(var i = 1; i < args.length; i++){
resultArray.push(args[i]);
}
return resultArray;
}

function toDestroy(num){
return this.indexOf(num) === -1;
}

function destroyer(arr) {

var valuesToDelete = extractExtraArguments(arguments);

return arr.filter(toDestroy, valuesToDelete);

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
‘''

wups no xD
function extractExtraArguments(args){
  var resultArray = [];
  for(var i = 1; i < args.length; i++){
    resultArray.push(args[i]);
  }
  return resultArray;
}

function toDestroy(num){
  return this.indexOf(num) === -1;
}

function destroyer(arr) {

  var valuesToDelete = extractExtraArguments(arguments);

  return arr.filter(toDestroy, valuesToDelete);

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
I managed to do this bonfire
but i don’t fully understand the use of this
this is just like other variable? because i came from Java where I used this to refer to a variable of the class where I was typing
Ahsan Naveed
@ahsannaveed007
Jun 23 2015 15:17
function convert(str) {
  // &colon;&rpar;

  var regEx =/[&><"']/g;
  var match = regEx.exec(str);

  if(!match){
    return str;
  }


  for (var i=0; i<match.length; i++){
    switch (match[i]){
      case '&':
        return str.replace('&','&amp;');

      case "'":
        return str.replace('\'','&apos;');

      case '"':
        return str.replace('"','&quot;');

      case '<':
        return str.replace('<','&lt;');

      case '>':
        return str.replace('>','&gt;');

      default:
        return str;
    }
  }
}

convert('<>’);
I am not able to pass test case (convert(‘<>’))
anyhelp would be greatly appreciated
Logan Tegman
@ltegman
Jun 23 2015 15:18
That test is currently broken. You'll need to skip that bonfire for now.
Ahsan Naveed
@ahsannaveed007
Jun 23 2015 15:18
s/anyhelp/any help
thanks @ltegman
Moisés Man
@moigithub
Jun 23 2015 15:19
@edgarshurtado ... from my poor understanding...... acording to https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Objetos_globales/Array/filter when u pass a 2nd argument to FILTER, this second argument will be referenced as "this"... so on ur toDestroy function will be like return [2,3].indexOf(num) === -1; // and num will be each numbers of [1, 2, 3, 1, 2, 3]
Edgar S. Hurtado
@edgarshurtado
Jun 23 2015 15:20
thanks for answering @moigithub that’s what I thought, however is a bit akward that use of the key word this
wow thank you @kmiasko ! I found a post in Spanish where it was explained aswell but here is much more deeply explained. I’ll check it out. Thanks!
Ahsan Naveed
@ahsannaveed007
Jun 23 2015 15:24
can they tell me if anyone can acess FreeCodeCamp.com
Moisés Man
@moigithub
Jun 23 2015 15:24
@ahsannaveed007 acording to ur code... when u run convert <>... first .. it will scan all matches,, then do a for loop... execute the first replace... and RETURNing a result,, BUT remember return.. will exit ur function.. so it will not have a chance to execute a SECOND replace
Ahsan Naveed
@ahsannaveed007
Jun 23 2015 15:29
@moigithub
function convert(str) {
  // &colon;&rpar;

  var regEx =/[&><"']/g;
  var match = regEx.exec(str);

  if(!match){
    return str;
  }


  for (var i=0; i<match.length; i++){
    switch (match[i]){
      case '&':
        str = str.replace('&','&amp;');

      case "'":
        str = str.replace('\'','&apos;');

      case '"':
        str = str.replace('"','&quot;');

      case '<':
        str = str.replace('<','&#60;');

      case '>':
        str = str.replace('>','&#62;');

      default:
        return str;

    }
  }
}

convert('<>');
@moigithub still not able to pass convert(‘<>’);
Moisés Man
@moigithub
Jun 23 2015 15:30
@ahsannaveed007 every time u replace something.. u store in str... but.. when ur function finish... u missing a return str; to give back the result
Ahsan Naveed
@ahsannaveed007
Jun 23 2015 15:32
@moigithub did you pass the testcase
function convert(str) {
  // &colon;&rpar;

  var regEx =/[&><"']/g;
  var match = regEx.exec(str);

  if(!match){
    return str;
  }


  for (var i=0; i<match.length; i++){
    switch (match[i]){
      case '&':
        str = str.replace('&','&amp;');

      case "'":
        str = str.replace('\'','&apos;');

      case '"':
        str = str.replace('"','&quot;');

      case '<':
        str = str.replace('<','&#60;');

      case '>':
        str = str.replace('>','&#62;');

      default:
        return str;

    }
  }
  return str;
}

convert('<>');
Moisés Man
@moigithub
Jun 23 2015 15:32
im on ziplines already... and yes i passed all
i did a chained replace
Ahsan Naveed
@ahsannaveed007
Jun 23 2015 15:33
still not passing it :P
Logan Tegman
@ltegman
Jun 23 2015 15:33
The second test case was only recently broken, so people who did this bonfire earlier were able to pass it
No one is currently able to
Ahsan Naveed
@ahsannaveed007
Jun 23 2015 15:33
oh I see @ltegman
Logan Tegman
@ltegman
Jun 23 2015 15:33
Devs have said a patch is pending and should be deployed in a couple days
Ahsan Naveed
@ahsannaveed007
Jun 23 2015 15:34
how would we get notified @ltegman
Logan Tegman
@ltegman
Jun 23 2015 15:35
@ahsannaveed007 That's a good question -- I don't know that we will be. I've just been trying it every day to see if it works yet :smile:
Adam Rehard
@adamrehard
Jun 23 2015 15:35
$(document).ready(function() {
    $('#button').click(function() {
        var toAdd = $('input[name=checkListItem]').val();
        $('list').append('<div class="item">' + toAdd + '</div>');
    });

});
I'm doing Modifying HTML on Codecademy. Doing ok til I got to this one. Anyone see what I'm doing
wrong?
Moisés Man
@moigithub
Jun 23 2015 15:36
@adamrehard what "list" is ?? a class ? an id ? probably missing .(dot) or #
Adam Rehard
@adamrehard
Jun 23 2015 15:36
list is a class.
Moisés Man
@moigithub
Jun 23 2015 15:36
$(".list") <-- with a dot
Edgar S. Hurtado
@edgarshurtado
Jun 23 2015 15:36
so you’re missing the .(dot) Don’t you?
Adam Rehard
@adamrehard
Jun 23 2015 15:36
That worked! Thanks!
Moisés Man
@moigithub
Jun 23 2015 15:36
:)
Jessi L Wasell
@JessiW
Jun 23 2015 15:45
I need a little help on the Bonfire Return the Largest Numbers in Arrays - can someone look at my code?
Krzysztof Miąsko
@kmiasko
Jun 23 2015 15:46
paste it on the channel
wrap it in ```
Jessi L Wasell
@JessiW
Jun 23 2015 15:47
function largestOfFour(arr) {
  var largestNum = [];
  for(var i = 0; i <arr.length; i++) {
    if (arr[i] > largestNum) {
    }
  }
  return largestNum;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Not sure what I'm doing wrong - seems like it should work to me :)
Logan Tegman
@ltegman
Jun 23 2015 15:49
@JessiW You're only looping over the outer array, so when you access arr[i] you are not accessing an individual number, you're accessing another array.
Krzysztof Miąsko
@kmiasko
Jun 23 2015 15:49
you don't have any assign of value, thats for sure
and arr[i] is one of the arrays, not values
Jessi L Wasell
@JessiW
Jun 23 2015 15:50
okay - I wondered if it was only accessing the outer array - how do I access the inner ones?
Krzysztof Miąsko
@kmiasko
Jun 23 2015 15:51
you need two nested loops, one for arrays, one for values
or use reduce in your for loop
Jessi L Wasell
@JessiW
Jun 23 2015 15:51
Okay - thanks - I'll try that :)
Luke Pensiero
@VonCrab
Jun 23 2015 15:53
I could use some help with the Bonfire: Symmetric Difference, I can't seem to get the last test (the single array) to pass.
keagan goetsch
@misterrorypond
Jun 23 2015 15:55
Help with BonfireTitle case? All but one test passes. I don't know what I'm doing wrong.
function titleCase(str) {
     return str.replace(/\w+/g, function(txt)
       {return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
    });
}

titleCase("I'm a little tea pot");
Krzysztof Miąsko
@kmiasko
Jun 23 2015 15:56
your w+ treats ' as a word separator
and testcase treats I'm as a whole word
so you're returning I'M
Jessi L Wasell
@JessiW
Jun 23 2015 15:57
I used /\w\s*/g for mine
keagan goetsch
@misterrorypond
Jun 23 2015 15:57
Thank you - I'm just having the worst time with regex
Mathieu Roy
@Mathieu-Roy
Jun 23 2015 15:58

MakeAPerson (Bonfire Intermediate 1)

I've used pseudoclassical objects we learned to do in the Object Oriented Javascript section, but I think that makes the test expect(Object.keys(bob).length).to.eql(6); because it has only 2: this.firstName and this.lastName; the 6 methods are in Person.prototype. Do you think my code would be good otherwise?
var Person = function(firstAndLast) {
    this.setFullName(firstAndLast);
};
Person.prototype = {
  getFirstName: function() {return this.firstName;},
  getLastName: function() {return this.lastName;},
  getFullName: function() {return this.firstName + " " + this.lastName;},
  setFirstName: function(first) {this.firstName = first;},
  setLastName: function(last) {this.lastName = last;},
  setFullName: function(firstAndLast) {
    this.firstName = firstAndLast.split(" ")[0];
    this.lastName = firstAndLast.replace(/^\w*\s/, "");
  }
};

var bob = new Person('Bob Ross');
bob.getFullName();
keagan goetsch
@misterrorypond
Jun 23 2015 15:58
@JessiW that makes it worse for me somehow
Jessi L Wasell
@JessiW
Jun 23 2015 15:59
wow - okay @misterrorypond - well, your code seems to look just like mine otherwise - I'll look again :)
keagan goetsch
@misterrorypond
Jun 23 2015 15:59
@JessiW Thanks! I can get all but 3 to pass with my current code, and none pass with that bit of Regex - I assume it has to be a regex issue
Krzysztof Miąsko
@kmiasko
Jun 23 2015 16:00
try /[A-z']+/g
keagan goetsch
@misterrorypond
Jun 23 2015 16:00
@kmiasko That fixed it!!!
Thanks so much!
regular expressions are confusing
Krzysztof Miąsko
@kmiasko
Jun 23 2015 16:01
yes, they are, i hate them ;)
Jessi L Wasell
@JessiW
Jun 23 2015 16:01
That's great - @misterrorypond - glad its fixed! :)
keagan goetsch
@misterrorypond
Jun 23 2015 16:02
Thanks all ^^
Vos
@KrisVos130
Jun 23 2015 16:03
@Mathieu-Roy It should be good otherwise I think, it's just a bigger object than what you can have
Mathieu Roy
@Mathieu-Roy
Jun 23 2015 16:04
@KrisVos130 Ok thanks. I'll try to figure out how to do it with all the tests passing now.
Vos
@KrisVos130
Jun 23 2015 16:05
@Mathieu-Roy As a tip, you can do everything without those this.firstName and this.lastName, and no variables outside of the object
Mathieu Roy
@Mathieu-Roy
Jun 23 2015 16:08
@KrisVos130 thanks for the tip; I was wondering just that ^^
Vos
@KrisVos130
Jun 23 2015 16:09
@Mathieu-Roy Yeah so was I yesterday, glad I could help :)
Mathieu Roy
@Mathieu-Roy
Jun 23 2015 16:13
@KrisVos130 Oh I think I just figured that I can return firstAndLast right in some functions of the constructor, and when an object will be created, all the firstAndLast variables in the constructor will be replaced by the value immediately! :o Like so:
var Person = function(firstAndLast) {
  this.getFirstName = function() {return firstAndLast.split(" ")[0];};
  this.getLastName = function() {return firstAndLast.replace(/^\w*\s/, "");};
  this.getFullName = function() {return firstAndLast;};
  };
};
Vos
@KrisVos130
Jun 23 2015 16:13
@Mathieu-Roy Yup, you figured it out! :D
@Mathieu-Roy The only thing I did differently was the getLastName, I did it without the regex, but there are more ways that lead to Rome
Mathieu Roy
@Mathieu-Roy
Jun 23 2015 16:14
@KrisVos130 :)
Mathieu Roy
@Mathieu-Roy
Jun 23 2015 16:28
@KrisVos130 I just figured out the second part. This was a really useful exercise! :)
Vos
@KrisVos130
Jun 23 2015 16:29
@Mathieu-Roy Yeah for sure, without them even directly saying it, I realised you can save on a lot of memory
Mathieu Roy
@Mathieu-Roy
Jun 23 2015 16:30
@KrisVos130 Right!
Vos
@KrisVos130
Jun 23 2015 16:33
@Mathieu-Roy The one after the Person bonfire is a bit confusing, so if you need any help just tell me :)
@Mathieu-Roy Once the site goes up again at least
Tom DeFrank
@TomDeFrank
Jun 23 2015 16:40
@misterrorypond @kmiasko Good help with regex: https://www.youtube.com/watch?v=EkluES9Rvak
Ahsan Naveed
@ahsannaveed007
Jun 23 2015 16:44

function smallestCommons(arr) {
  var i=0;
  var n1 = arr[0];
  var n2 = arr[1];
  var arrOf_n1 = [n1];
  var arrOf_n2 = [n2];

  while(arrOf_n1[i] !== arrOf_n2[i]);{
    arrOf_n1.push(arrOf_n1[i]+n1);
    arrOf_n2.push(arrOf_n2[i]+n2);
    i++;
  }

  return arrOf_n1;
}


smallestCommons([1,5]);
any suggestions
is there any problem with the while logic
Krzysztof Miąsko
@kmiasko
Jun 23 2015 16:48
you have ; after while()
so it looks like infinite
Krzysztof Miąsko
@kmiasko
Jun 23 2015 16:54
and when you'll get [1,5] you will produce infinite number of [1,2,3,...] [5,10,15,...] so they'll never be ===
if i analyze this corectly
reading other ppl code is so hard o.O
not 1,2,3 but 1,2,4,6,10.. etc
hehehe, wrong again
Ahsan Naveed
@ahsannaveed007
Jun 23 2015 16:58
any suggestions @kmiasko
Krzysztof Miąsko
@kmiasko
Jun 23 2015 16:59
start over, i don't know what you want to achieve here
Ahsan Naveed
@ahsannaveed007
Jun 23 2015 17:00
actually I am bonfire # 32
Krzysztof Miąsko
@kmiasko
Jun 23 2015 17:00
or maybe someone else gets it
Ahsan Naveed
@ahsannaveed007
Jun 23 2015 17:00
Smallest common multiple
Krzysztof Miąsko
@kmiasko
Jun 23 2015 17:05
you need to find smallest number, that it's modulo for all numbers between arr[0] and arr1 is 0
or from arr1 to arr[0], depends which one is greater
*arr1
uh, what is that autocorrection
Ahsan Naveed
@ahsannaveed007
Jun 23 2015 17:12
thanks @kmiasko
Candis Wasell
@CandiW
Jun 23 2015 17:49
Hi - I'm working on a learnyounode challenge Juggling Async.....I'm a bit stuck :) is anyone able to look over my code and give me a few pointers?
var http = require("http");
var bl = require('bl');
var EventEmitter = require('events');

http.get(process.argv[2], process.argv[3], process.argv[4], function(response, callback){
    response.setEncoding('utf8');
    response.pipe(bl(function(err,data) {
        if (err) console.error (err);
        data = data.toString();
        console.log(data.length);
        console.log(data);
    response.on(EventEmitter(function(err, msg) {
        if(err) console.error(err);
        var myEmitter = function(msg){
            msg = 'listening';
            console.log(myEmitter);
        }; callback(myEmitter, data);
    }));
    }));
});
I'm receiving an error that says 'listener must be a function' ??
Moisés Man
@moigithub
Jun 23 2015 17:53
thats a zipline ?
Krzysztof Miąsko
@kmiasko
Jun 23 2015 17:54
waypoint
Candis Wasell
@CandiW
Jun 23 2015 17:54
right - a waypoint
I'm learning node.js so I could have more than one mistake
Moisés Man
@moigithub
Jun 23 2015 17:55
full stack i guess... cuz didnt saw that yet.... im still on ziplines
Candis Wasell
@CandiW
Jun 23 2015 17:56
ok - that's alright
Moisés Man
@moigithub
Jun 23 2015 17:57
on random quotes generator... is necesary to add twitter ? or can skip that ? :D... or any good tutorials for noobs ?
Krzysztof Miąsko
@kmiasko
Jun 23 2015 17:59
you have user stories, and bonus user stories
bonus are optional
Krzysztof Miąsko
@kmiasko
Jun 23 2015 18:00
wow, gitter show it differently than slack
nice one, congrats
sorry @CandiW can't help you, i did it long time ago and without doing it again i'm stuck like you
maybe ask on main channel
there is many more ppl
Candis Wasell
@CandiW
Jun 23 2015 18:03
That's ok - thanks anyway :)
Abdul R. Taleb-Agha
@atalebagha
Jun 23 2015 18:05
Hi everyone
I need help on Bonfire Seek and Destroy Here’s my code:
```
BL Hill
@montythemack
Jun 23 2015 18:06
Anyone have any tips for tackling the Bonfire: Map The Debris?
Abdul R. Taleb-Agha
@atalebagha
Jun 23 2015 18:06
function destroyer(arr) {

  function rem(value) {
    for (var i = 1; arguments.length; i++) {
      if (value == arguments[i]) {
        return false;
      } else {
        return true;
      }
    }
  }
  return arr.filter(rem);
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Den McHenry
@denmch
Jun 23 2015 18:06
@montythemack Use .map().
@atalebagha arguments.length can't be the condition by itself.
It should be something like i < arguments.length
Abdul R. Taleb-Agha
@atalebagha
Jun 23 2015 18:09
yah I cought that
still not working though
thanks
mientje
@mientje
Jun 23 2015 18:09
I gave the object a name, created an extra key for the object, attached the entire formula to that, deleted the avgAlt key-value pair and put the whole thing in a loop that deals with 3 objects
Abdul R. Taleb-Agha
@atalebagha
Jun 23 2015 18:09
I changed it to:
for (var key in arguments)
Den McHenry
@denmch
Jun 23 2015 18:10
@atalebagha That's not the solution, but it's a major issue with your code.
I think it's best not to use for in loops with arrays. They're made for objects.
Abdul R. Taleb-Agha
@atalebagha
Jun 23 2015 18:10
isn’t argument an object?
BL Hill
@montythemack
Jun 23 2015 18:13
I'm more confused by the calculation needed @denmch
mientje
@mientje
Jun 23 2015 18:17
you make the sum of earthradius and avgalt and that som to the power of three, you take the square root of that sum to the power of three and divide the entire thing by GM - when that is done you multiply everything by (pi * 2) - use math.PI, math.pow, math.round and math.sqrt
Patrick Metzdorf
@batjko
Jun 23 2015 18:18
"arguments" is a pseudo object. it's kinda like an array but lacks most of its properties. I think only .length works with it?
Den McHenry
@denmch
Jun 23 2015 18:18
@montythemack The equation for the orbital period is T = 2pi sqrt(r^3 / GM).
Where r is the semi major axis.
Steven Leiva
@StevenXL
Jun 23 2015 18:19
Can someone help me understand why my telephoneCheck function returns false for the string "(555)555-5555"
Here is my code:
function telephoneCheck(str) {
    var found = str.search(/\(?\d{3}[\(|-]\d{3}-\d{4}/);

    if (found !== -1) {
        return true;
    }

    return false;
}
mientje
@mientje
Jun 23 2015 18:19
earthRadius + avgalt
Abdul R. Taleb-Agha
@atalebagha
Jun 23 2015 18:19
thanks @batjko
Steven Leiva
@StevenXL
Jun 23 2015 18:19
it returns true if I leave off -\d{4} from the RegEx
Patrick Metzdorf
@batjko
Jun 23 2015 18:19
yup
Steven Leiva
@StevenXL
Jun 23 2015 18:20
but I don't see why that's the case.
Moisés Man
@moigithub
Jun 23 2015 18:20
wheres the closing )
Den McHenry
@denmch
Jun 23 2015 18:20
@atalebagha Look into using .filter().
Steven Leiva
@StevenXL
Jun 23 2015 18:21
@moigithub Good catch. I need to replace the [\(|-] with [\)|-]
Turn around the closing parenthesis
yup - that fixed it!
thank you
Moisés Man
@moigithub
Jun 23 2015 18:21
:smile:
Abdul R. Taleb-Agha
@atalebagha
Jun 23 2015 18:23
thanks @denmch
Steven Leiva
@StevenXL
Jun 23 2015 18:23
I skipped over this bonfire because RegEx is scary
Abdul R. Taleb-Agha
@atalebagha
Jun 23 2015 18:23
Am I hot or cold with my the following
function destroyer(arr) {

    function rem(value) {
    for (var i = 1; i < arguments.length; i++) {
      if (value == arguments[i]) {
        return false;
      } 
    }
    return true;
  }

  return arr.filter(rem);
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Steven Leiva
@StevenXL
Jun 23 2015 18:23
but I'm tackling it one argument at a time
;)
Jessi L Wasell
@JessiW
Jun 23 2015 18:31
Hi I was here a little earlier for help on the Bonfire: Return Largest Numbers in Arrays - I've written more code and am now getting an error saying 'largest is not a function' - here's my code.....
function largestOfFour(arr) {
  var largest = [];

  for (var i = 0; i<arr.length; i++) {
      num = largest(arr[i]);
      largest.push(num);
    }
function largestNum(subArr) {
  var largeNum = 0;
  for(var n = 0; n<subArr.length; n++) {
    if(subArr[n]>largeNum) {
      largeNum = subArr[n];
    }
   return largeNum; 
  }
}
  return largest;
 }


largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
If someone could help me - I'd appreciate it :)
Steven Leiva
@StevenXL
Jun 23 2015 18:33
@moigithub Is it possible to have multiple "or" in one group. Like so: [a|b|c] and have that match a, or b, or c
silvanatsp
@silvanatsp
Jun 23 2015 18:33
hey i am kind of stuck with the submit button in the kitty app.
<button type='submit'><form action="/submit-cat-photo">
<input type='text' placeholder='cat photo URL'>
</form></button>.
if someone could help me
Moisés Man
@moigithub
Jun 23 2015 18:33
@JessiW function largestNum(subArr) <-- ur function name is "largestNum".. not largest
Jessi L Wasell
@JessiW
Jun 23 2015 18:34
omg - thanks :)
Moisés Man
@moigithub
Jun 23 2015 18:36
@StevenXL if u using "square brackets" [ ],, it means any character u have inside.. (so no | needed ) ... if u wanna use | or use parenthesis (a|b|c)
Steven Leiva
@StevenXL
Jun 23 2015 18:36
Ah thanks
I'm kind of confused by what parenthesis do versus square brackets. Parenthesis are a capture group, and square brackets are just a grouping?
Jessi L Wasell
@JessiW
Jun 23 2015 18:38
@moigithub do I need two return statements or just one?
Moisés Man
@moigithub
Jun 23 2015 18:38
@StevenXL yep.. kind of
@JessiW on largestNum function.. only 1 return, after u checked all nums at end
Jessi L Wasell
@JessiW
Jun 23 2015 18:40
okay - thank you @moigithub :)
Logan Tegman
@ltegman
Jun 23 2015 18:42
@atalebagha Close, but when you're calling arguments[i] in your rem function you only have access to the arguments that were passed to the rem function, not the arguments of the destroyer function.
Jessi L Wasell
@JessiW
Jun 23 2015 18:45
So I changed my code to have only one return statement (return largestNum) at the end and I'm still gettting the 'largest is not a function error' - is there something else in my code that's wrong?
Steven Leiva
@StevenXL
Jun 23 2015 18:49
I did it guys!
I passed the Validate U.S. Phone Number Bonfire.
Thanks @moigithub for your help!
OK - back to work. I love this stuff but I need a way to keep the lights on.
Jessi L Wasell
@JessiW
Jun 23 2015 18:51
Here's my code again -
Moisés Man
@moigithub
Jun 23 2015 18:51

num = largest(arr[i]); <--- should be num = largestNum(arr[i]);

cuz thats how u named ur function

function largestNum(subArr) { ....

Jessi L Wasell
@JessiW
Jun 23 2015 18:54
Okay - I changed that
Now I'm printing out the whole code for the largestNum function!
Moisés Man
@moigithub
Jun 23 2015 18:56
...share ur code :)
Jessi L Wasell
@JessiW
Jun 23 2015 18:56
Um I think I'm not getting something here....sorry :(
okay - here it is again.....
function largestOfFour(arr) {
  var largest = [];

  for (var i = 0; i<arr.length; i++) {
      num = largestNum(arr[i]);
      largest.push(num);
    }
function largestNum(subArr) {
  var largeNum = 0;
  for(var n = 0; n<subArr.length; n++) {
    if(subArr[n]>largeNum) {
      largeNum = subArr[n];
    } 
  }
}
  return largestNum;
 }

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Ariel
@ArielLeslie
Jun 23 2015 18:58
you're returning largestNum instead of largeNum
Jessi L Wasell
@JessiW
Jun 23 2015 18:58
I also tried changing the largest.push(num) to largestNum.push(num) and it told me largestNum.push was not a function
Rasheed Bustamam
@abustamam
Jun 23 2015 18:58
Jessi you also aren't returning the largets array
Ariel
@ArielLeslie
Jun 23 2015 18:59
yup you're returning the function
Logan Tegman
@ltegman
Jun 23 2015 18:59
also, largestNum isn't returning anything. It looks like it should be returning the largeNum variable when it completes.
Jessi L Wasell
@JessiW
Jun 23 2015 18:59
okay - I had that before but I thought I only needed one return statement? @abustamam
Rasheed Bustamam
@abustamam
Jun 23 2015 19:00
you have two functions
each function should have its own return statement
Ariel
@ArielLeslie
Jun 23 2015 19:00
It looks like you have one function inside of the other, if I'm counting brackets right.
Rasheed Bustamam
@abustamam
Jun 23 2015 19:00
so for largestNum, you want to return largeNum
Jessi L Wasell
@JessiW
Jun 23 2015 19:00
Okay - that's what I thought @abustamam - just a sec :)
Moisés Man
@moigithub
Jun 23 2015 19:01
a function inside another function ( i think is called closure ? )
Rasheed Bustamam
@abustamam
Jun 23 2015 19:01
inception o.o
Ariel
@ArielLeslie
Jun 23 2015 19:01
closure is something different
Rasheed Bustamam
@abustamam
Jun 23 2015 19:01
you can return anonymous functions, that's more closure-y
but a bit complex for these bonfires :D
Jessi L Wasell
@JessiW
Jun 23 2015 19:02
I'm reworking the names so I stop confusing myself - I'll share my code again in a minute :)
haha
Ariel
@ArielLeslie
Jun 23 2015 19:03
function largestOfFour(arr) {
  var largest = [];

  for (var i = 0; i<arr.length; i++) {
      num = largestNum(arr[i]);
      largest.push(num);
    }
return largest;
}
function largestNum(subArr) {
  var largeNum = 0;
  for(var n = 0; n<subArr.length; n++) {
    if(subArr[n]>largeNum) {
      largeNum = subArr[n];
    } 
  }
return largeNum;
}
Lightwaves
@Lightwaves
Jun 23 2015 19:03
@abustamam so instead of returning a value you'd return an inner nested function or am I completely lost.
Ariel
@ArielLeslie
Jun 23 2015 19:03
Not checking your logic, that should at least untangle your functions
@Lightwaves No need to nest the functions. Just call one from the other. :D
Jessi L Wasell
@JessiW
Jun 23 2015 19:04
Okay thanks @arielleslie - I'll try that :)
It worked!!!! Thanks so much everyone - I really appreciate it @arielleslie @abustamam @Lightwaves @moigithub :)
Ariel
@ArielLeslie
Jun 23 2015 19:07
congrats!
Jessi L Wasell
@JessiW
Jun 23 2015 19:07
thanks for your help :)
Lightwaves
@Lightwaves
Jun 23 2015 19:07
"I didn't do anything! I swear!"
"I did not take your car keys"
Jessi L Wasell
@JessiW
Jun 23 2015 19:08
haha :) have a good day
Lightwaves
@Lightwaves
Jun 23 2015 19:12
this is pretty amusing here is a loop that crashes your browser please for the love of all that is holy don't run it..
Ahsan Naveed
@ahsannaveed007
Jun 23 2015 19:24
is there something wrong with BONFIRE: Drop it
function drop(arr, func) {
  // Drop them elements.
  for(var i=0; i<arr.length; i++){
    if(!func(arr[i])){
      arr.shift();
    }
  }
  return arr;
}

drop([1, 2, 3], function(n) {return n <= 3; });
Logan Tegman
@ltegman
Jun 23 2015 19:29
@ahsannaveed007 One problem with your solution is that you're incrementing your index value of the for loop at the same time as you're shifting items off the array, so you're going to skip over some elements of the array.
For this problem I would personally use a while loop that is set to stop when there are no elements left in the array, and keep accessing the first element of the array as you shift items off.
Ahsan Naveed
@ahsannaveed007
Jun 23 2015 19:36
oh make sense @ltegman
thanks a lot @ltegman
Suzanne Atkinson
@AdventureBear
Jun 23 2015 19:37
can you use filter and slice for that?
Ahsan Naveed
@ahsannaveed007
Jun 23 2015 19:38
@ltegman great solution :)
ronaldrdguez
@ronaldrdguez
Jun 23 2015 19:39
@ahsannaveed007 Instead of using shift you could keep your for loop and return arr.slice(i) once func() becomes true.
Rasheed Bustamam
@abustamam
Jun 23 2015 19:41
@Lightwaves don't worry about closures for now, or returning functions. I'm up to mutations so far and haven't needed to use closures.
Lightwaves
@Lightwaves
Jun 23 2015 19:51
@abustamam more for my personal knowledge, more interested in getting better at thinking in a functional way.
@abustamam I'd probably complete most of the bonfires procedurally then go back and do them functionally.
Eric Tillberg
@Thrillberg
Jun 23 2015 19:55
can anyone help me with the DNA bonfire?
Ariel
@ArielLeslie
Jun 23 2015 19:57
I haven't done that one, but you can throw up you're code and describe your problem.
*your
ronaldrdguez
@ronaldrdguez
Jun 23 2015 19:58
@Thrillberg what do you have so far?
Eric Tillberg
@Thrillberg
Jun 23 2015 19:59
@ronaldrdguez well, nothing thats the problem :) I don't understand what the task is
oh wait, maybe now i get it... they give the first letter of each pair and i have to match it to its pair?
ronaldrdguez
@ronaldrdguez
Jun 23 2015 20:00
Yup
Eric Tillberg
@Thrillberg
Jun 23 2015 20:02
ok that makes sense now... i'll give it a shot
ronaldrdguez
@ronaldrdguez
Jun 23 2015 20:04
I find bonfire instructions so vague and unclear, Most of the timeI need to run the emtpy code and look at the failed tests just to figure out what I’m supposed to solve.
Eric Tillberg
@Thrillberg
Jun 23 2015 20:04
yeah i tried that and figured out the pattern
Godfrey Chiu
@ggwc82
Jun 23 2015 20:04
is anyone here that can help me with the symmetric difference advanced bonfire?
actually - ignore the above, I think I figured it out!
michaelpcampbell
@michaelpcampbell
Jun 23 2015 20:25

<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>

<style>
.red-text {
color: red;
}

h2 {
font-family: Lobster, Monospace;
blue-text
}

p {
font-size: 16px;
font-family: Monospace;
}
</style>

<h2 class='red-text' class= "blue-text" class= "urgently-red">CatPhotoApp</h2>

<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

having trouble adding important declaration
blue text and urgently red
to h2
Jeff Wilkey
@JeffWilkey
Jun 23 2015 20:26
blue-text will actually be its own css style like this:
.blue-text {
  color:blue
}
michaelpcampbell
@michaelpcampbell
Jun 23 2015 20:26
so how many styles can you have in code
Jeff Wilkey
@JeffWilkey
Jun 23 2015 20:27
as many as you want
michaelpcampbell
@michaelpcampbell
Jun 23 2015 20:28
ok i already have an h2 style where do i put it or just make another style all together
Jeff Wilkey
@JeffWilkey
Jun 23 2015 20:29
This would be correct code ```
oop sorry one sec
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<style>
  .red-text {
    color: red;
  }

  .urgently-red {
    color: red !important;
  }

  .blue-text {
    color: blue;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }
</style>

<h2 class='blue-text urgently-red'>CatPhotoApp</h2>

<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
michaelpcampbell
@michaelpcampbell
Jun 23 2015 20:31
ok so the style is referring to whats inside the brackets of style
Jeff Wilkey
@JeffWilkey
Jun 23 2015 20:31
notice how the styles blue-text and urgently-red are created within the style tag then applied to the h2 html tag like this: <h2 class='blue-text urgently-red'>CatPhotoApp</h2>
michaelpcampbell
@michaelpcampbell
Jun 23 2015 20:31
ok i get it now
Jeff Wilkey
@JeffWilkey
Jun 23 2015 20:31
Awesome :)
michaelpcampbell
@michaelpcampbell
Jun 23 2015 20:32
thanks
Terrell Vest
@MirPresT
Jun 23 2015 20:33
can someone help clarify the directions for the convert html bonfire.... no sure what it's asking to do.
Logan Tegman
@ltegman
Jun 23 2015 20:37
@MirPresT The challenge is asking you to turn the special characters in a string into their HTML entity -- so "&" would become "&", "<" would become "<", etc
You can find all the relevant HTML entities at http://dev.w3.org/html5/html-author/charref
Terrell Vest
@MirPresT
Jun 23 2015 20:38
@ltegman i have access to the entities... so wouldnt it be more like ">" becomes &rt.....?
Logan Tegman
@ltegman
Jun 23 2015 20:39
sorry, I forgot it converts the HTML entities in the chat, that should have said &amp; and &lt;
Terrell Vest
@MirPresT
Jun 23 2015 20:40
@ltegman have you completed this one? Would I be able to use .replace() ?
Logan Tegman
@ltegman
Jun 23 2015 20:41
@MirPresT Yup, replace is a good way to go. Just be aware that currently test case two for this bonfire is broken, so even if you get the right answer if will not pass and you'll need to skip onto the next one for now.
Terrell Vest
@MirPresT
Jun 23 2015 20:42
@ltegman thats what i thought.. I noticed there erros did not make sense...
@ltegman thanks.
Logan Tegman
@ltegman
Jun 23 2015 20:43
@MirPresT np :smile:
Terrell Vest
@MirPresT
Jun 23 2015 20:50
@ltegman have you completed the next one ? How am i supposed to insert a dash when a string has no spaces..... I mean i could insert a space every nth time or something but that wouldnt work for every word etc.....
for the spinal tap case...
Moisés Man
@moigithub
Jun 23 2015 20:51
any1 know a FREE weather api site with NO registration required or NO key? googled but all i saw want me register
Logan Tegman
@ltegman
Jun 23 2015 20:51
@MirPresT You'll need to dive further into regex patterns so that you can get the replace method to find any instance of a capital letter that is preceded by a lowercase letter.
You
You'll probably need to use capture groups to preserve what you find while also inserting the new characters
Terrell Vest
@MirPresT
Jun 23 2015 20:53
gotcha..... can you tell I speed through the reg x course ??? ;)
Logan Tegman
@ltegman
Jun 23 2015 20:53
@moigithub I don't remember it off the top of my head but I think NOAA has an open API
@moigithub Nvm, I think it requires an API key
@MirPresT Hahaha, I can understand that. Regex probably was (and sometimes still is) one of my biggest stumbling blocks in programming.
Terrell Vest
@MirPresT
Jun 23 2015 20:55
reading it was so dry... anyways.. at least i have something to look forward to lol off for now. thanks for the assistance...
RaissaHughes
@RaissaHughes
Jun 23 2015 20:58
Hey guys !!! !!! :)
Logan Tegman
@ltegman
Jun 23 2015 20:59
Hello @RaissaHughes ! :smile:
RaissaHughes
@RaissaHughes
Jun 23 2015 20:59

// Check if the user is ready to play!
confirm("I understand confirm!")

var age = prompt("What's your age");
if(age < 13)
{
console.log("You are allowed to play but I take no responsibilty!")
}
else (age > 13)
{
console.log("Have fun!")

}

console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");

it says my code is wrong somewhere ... im on 3/7 code academy javascript create your own adventure game waypoint

please help <2
<3**
Logan Tegman
@ltegman
Jun 23 2015 21:04
Hmmm, I'm not sure. The code looks fine to me. And it passed when I ran your exact code in Codecademy myself :/
Moisés Man
@moigithub
Jun 23 2015 21:04
else (age > 13)
missing IF
Logan Tegman
@ltegman
Jun 23 2015 21:05
@moigithub Good catch! Makes me wonder how many other codecademy answers I got wrong if it let me pass with that code on my machine XD
RaissaHughes
@RaissaHughes
Jun 23 2015 21:19
im still kinda conf cause its still not working ... not sure what tochange
Steven Leiva
@StevenXL
Jun 23 2015 21:21
@moigithub dude - you're awesome at catching these tiny errors.
RaissaHughes
@RaissaHughes
Jun 23 2015 21:22
im a total noobie.. like im about 2 weeks into free code camp
:(

confirm("I understand confirm!")

var age = prompt("What's your age");
if(age < 13)
{
console.log("You are allowed to play but I take no responsibilty!")
}
else
if (age > 13)

{
console.log("Have fun!")

}

console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");

still not working
Lightwaves
@Lightwaves
Jun 23 2015 21:37
you want to instead just use else
pretty much your age isn't under 13 then you are obviously older so you don't need to perform another check unless it's for something specfic
Lightwaves
@Lightwaves
Jun 23 2015 21:42
Here's an example
if (age < 18){
    console.log("You can't do much of anything you are a minor.");

}
else if (age == 18){
    console.log("Congrats you can now smoke.");

}
else if (age < 21){
   console.log("Can't drink yet but hey being 18 or older means you can vote!");


}
else{
   console.log("Congrats you are now 21 or older and are a full adult, you can drink smoke and do anything you want as long as it's legal");

}
hopefully that's right.
whoops did make a small mistake
Steven Leiva
@StevenXL
Jun 23 2015 21:44
Hey guys
Lightwaves
@Lightwaves
Jun 23 2015 21:44
there we go
Steven Leiva
@StevenXL
Jun 23 2015 21:44
Has anyone done the No Repeats / Permutations Bonfire?
I'm just wondering can be solved mathematically or if it is simply brute-forcing.
Lightwaves
@Lightwaves
Jun 23 2015 21:45
I think it might have a mathmatical solution
unfortunately I've not done it so I could be wrong.
Timothy Touch
@timtouch
Jun 23 2015 21:46
If it did, I couldn't find it. I just brute forced it.
Steven Leiva
@StevenXL
Jun 23 2015 21:47
@Lightwaves I've tried to look for a mathematical solution, but they suggest using RegExp in the Bonfire.
That suggestion makes me think they are leading you towards brute-force.
@timtouch I have 3 more Bonfires before I move on to the Ziplines.
I took a look at the Ziplines - they seem very interesting.
The first problem - Twitch.tv API - ups the difficulty substantially I think.
Just from my perusing it
Timothy Touch
@timtouch
Jun 23 2015 21:50
They are quite the challenge for me since I never used APIs before
Luckily someone was willing to partner with me and I learned how to use them from him
Steven Leiva
@StevenXL
Jun 23 2015 22:00
Nice.
Ariel
@ArielLeslie
Jun 23 2015 22:01
@StevenXL with powerful regular expressions, I wouldn't classify it as brute forcing
but you certainly could do it mathematically
Ariel
@ArielLeslie
Jun 23 2015 22:07
It would require counting the number of unique characters and probably using a more powerful math library
RaissaHughes
@RaissaHughes
Jun 23 2015 22:08
@moigithub appreciate the help earlier, thanks!!!
Luke Pensiero
@VonCrab
Jun 23 2015 22:26
So the advanced algorithm bonfires are... advanced
Anyone have any advice for approaching the problems
Quincy Larson
@QuincyLarson
Jun 23 2015 22:29
@VonCrab My advice is to look closely at the MDN links provided
Hundreds of campers have finished them. http://media.giphy.com/media/yoJC2K6rCzwNY2EngA/giphy.gif
michaelpcampbell
@michaelpcampbell
Jun 23 2015 22:35
@michaelpcampbell
im a little stuck here http://www.freecodecamp.com/challenges/waypoint-give-a-background-color-to-a-div-element
its asking to create a style in background gray and give the div a class of background gray right?
Ariel
@ArielLeslie
Jun 23 2015 22:35
@VonCrab I also recommend the book "Cracking the Coding Interview" not just for interview advice but how to break down a problem and choose the right problem solving approach
Luke Pensiero
@VonCrab
Jun 23 2015 22:36
@QuincyLarson haha, thanks for the gif. It's something like looking at a blank page when writing, where does one start?
@arielleslie I'll check that out, thanks
Ariel
@ArielLeslie
Jun 23 2015 22:37
@michaelpcampbell You are going to create a class with a grey background. Then you are going to create a div of that class.
michaelpcampbell
@michaelpcampbell
Jun 23 2015 22:38
heres what i have
Ariel
@ArielLeslie
Jun 23 2015 22:38
.myclass{
    thing: how_i_want_it;
}

<tag class="myclass> insides</tag>
only wit the correct closing " :P
michaelpcampbell
@michaelpcampbell
Jun 23 2015 22:39
@arielleslie
Luis Hernandez
@luishrd
Jun 23 2015 22:47
hello
has anyone experienced problems connecting to FCC when behind a Watchguard Firewall?
I can't connect
Capture.PNG
maybe those localhost:3000 should not be there
Luis Hernandez
@luishrd
Jun 23 2015 22:53
thanks, the first link shows how to change the deny message and the second is viewable to experts-exchange members only.
the problem seems to be a long header line
Anthony Harrington
@GhostParticle
Jun 23 2015 22:55

Seriously... what am i doing wrong here, it will change x to uppercase... ???

while (z < c.length) {
var x = c.charAt(z);
test = (/[a-z]/).test(x);
if (test === true) {
x.toUpperCase();
}
console.log(x);
z++;
}

Ariel
@ArielLeslie
Jun 23 2015 22:58
is your z++ in your while loop?
Anthony Harrington
@GhostParticle
Jun 23 2015 22:58
yes
Ariel
@ArielLeslie
Jun 23 2015 22:59
sorry. hard to read the copy-paste
Anthony Harrington
@GhostParticle
Jun 23 2015 22:59
yea, i know,
Ariel
@ArielLeslie
Jun 23 2015 22:59
what behavior are you getting instead?
Anthony Harrington
@GhostParticle
Jun 23 2015 23:00
its like its not even running the if statement at all, it will print out fine, but it doesnt change the lowercase letters to the uppercase letters
Ariel
@ArielLeslie
Jun 23 2015 23:00
does test() maybe expect a string and not work on a char?
Anthony Harrington
@GhostParticle
Jun 23 2015 23:00
i would expect it would work on any variable
Ariel
@ArielLeslie
Jun 23 2015 23:02
looks like it should work on a char
Anthony Harrington
@GhostParticle
Jun 23 2015 23:03
there has to be something that is missing entirely
Ariel
@ArielLeslie
Jun 23 2015 23:05
wait. try x = x.toUpperCase();
toUpperCase() might be returning a value instead of modifying x
It's been a while since I've javaScripted
Anthony Harrington
@GhostParticle
Jun 23 2015 23:06
BAMMMM... Your awesome... i totally missed that..
Ariel
@ArielLeslie
Jun 23 2015 23:06
YAY :sparkles:
Anthony Harrington
@GhostParticle
Jun 23 2015 23:06
i knew there was something missing because everything else looked correct
tjstinso
@tjstinso
Jun 23 2015 23:40
in the advanced algorithms section, on the Bonfire: no repeats, i created a list of all permutations then filtered them based on repeating values. which worked for me. However, I was wondering if anyone knew of a mathematical, more elegant way to solve the problem. I felt mine was somewhat of a bruteforce solution.
Jeremiah Biard
@jeremiahbiard
Jun 23 2015 23:55
@arielleslie that's correct, because strings are immutable in javascript
@GhostParticle if you want to paste code, you can put it between three backticks
Moisés Man
@moigithub
Jun 23 2015 23:59
http://codepen.io/MMan/full/OVOmbP almost done.. just need to find some pics :)