These are chat archives for FreeCodeCamp/Help

25th
Jun 2015
Moisés Man
@moigithub
Jun 25 2015 00:02

@willamgriffin u could do something like

for(i=0;i<arr0.length;i++)
var toSearch = arr1.charAt(i);
if (arr0.indexOf(toSearch) < 0 && toSearch.length > 0 ) {

so arr1 will never be "" (empty)
"hey".charAt( 1000 ) <-- non existant char.. return "" (empty)

well.. arr1 will be emtpy.. but the filter (IF) condition will not let it pass
willamgriffin
@willamgriffin
Jun 25 2015 00:04
ah i see
thanks
tried that seems to give me same issue
going to have to limit the search length before the for loop
Moisés Man
@moigithub
Jun 25 2015 00:08
ahh ok.. i rechecked code :)
lemme repost ur code...
  • return EXIT the function *
    function mutation(arr) {
    arr0=arr[0];
    arr1=arr1;
    arr0=arr0.toLowerCase();
    arr1=arr1.toLowerCase();
    for(i=0;i<arr0.length;i++)
      if (arr0.indexOf(arr1.charAt(i)) < 0) {
          return false;
     }else{
         return true;
     }
    }
    mutation(['hello', 'hey']);
so... knowing.. "return EXIT the function"
IF it find or not ( if (arr0.indexOf(arr1.charAt(i)) < 0)) ur for loop will only iterate 1 time (check first character) and exit the function
not checking all other characters
willamgriffin
@willamgriffin
Jun 25 2015 00:15
ooooh i see
ok gotta eat dinner now will sort it out later
thanks
function mutation(arr) {
arr0=arr[0];
arr1=arr[1];

arr0=arr0.toLowerCase();
arr1=arr1.toLowerCase();

  for(i=0;i<arr0.length;i++)

  if (arr0.indexOf(arr1.charAt(i)) < 0 ){
    {return false;
  }
  }
      return true;

}

mutation(['hello', 'hey']);
that fixed it
thanks for your help so stupid thinking i could use return false or true like that
Harshit Kedia
@harshitKedia
Jun 25 2015 00:25
i am stuck here:"Zipline: build a Random Quote Machine". Before this, they only taught me basic HTML and CSS. I cannot build that app.
what should I do?
Moisés Man
@moigithub
Jun 25 2015 00:27
u did all previous exercises already ??
waypoints / bonfires
Harshit Kedia
@harshitKedia
Jun 25 2015 00:28
No. I have done the 29 challenges which the tutorial made me do.
Moisés Man
@moigithub
Jun 25 2015 00:31
probably u should go back n do the previous exercises first :)
Harshit Kedia
@harshitKedia
Jun 25 2015 00:33
i see
Jessi L Wasell
@JessiW
Jun 25 2015 00:45
Hi - I'm having some trouble with the Chunky Monkey Bonfire - my code isn't complete - was wondering if I need to use split() to split the array?
Lightwaves
@Lightwaves
Jun 25 2015 00:45
I'm actually having a bit of trouble with that one too.
Jessi L Wasell
@JessiW
Jun 25 2015 00:47
Okay @Lightwaves - was thinking I needed to use split() since it said to 'split' the array - or am I just hung up on a word? What do you think?
Here's my code - it doesn't work and is very incomplete I know...but here it is anyway @Lightwaves ```
function chunk(arr, size) {
  var array = [];

  for(var i = 0; i <arr.length; i++) {
    abc = arr.split(size.length);
     array.push(abc);
  }

  }

chunk(['a', 'b', 'c', 'd'], 2);
Lightwaves
@Lightwaves
Jun 25 2015 00:50

split in the sense of group a number of them according to the size so if the size is 3 and you have an array with 6 letters then the grouping should be

[[a,b,c] [e,f,g]]

Robert Ozimek
@robertozimek
Jun 25 2015 00:50
@JessiW no your suppose to take the array and make it multidimensional no actual splitting.. so [[‘a’, ‘b’], [‘c’, ’d’]]
Lightwaves
@Lightwaves
Jun 25 2015 00:50
yes exactly
Jessi L Wasell
@JessiW
Jun 25 2015 00:50
Okay - that helps me a bit - I was a bit lost :)
Thanks @Lightwaves @robertozimek @mattkuo :) - I'll keep working on it...
Lightwaves
@Lightwaves
Jun 25 2015 00:57
ohh so a take higher order function is just a slice call hmm
Jessi L Wasell
@JessiW
Jun 25 2015 01:22
Okay - I think I'm on the right track with the Chunky Monkey Bonfire now - but its returning all but the 'c' !!! Here's my code:
function chunk(arr, size) {
   var arrOne = [];
   var arrTwo = [];
 for (var i = 0; i<arr.length; i++) {
   arrOne = arr.slice(i, i+size);
   arrTwo.push(arrOne);
   i += size;
 }
  return arrTwo;
}

chunk(['a', 'b', 'c', 'd'], 2);
Lightwaves
@Lightwaves
Jun 25 2015 01:24
haha I got side tracked on my progress
was talking to a fcc-er
Jessi L Wasell
@JessiW
Jun 25 2015 01:24
its returning this : [["a", "b"],["d"]]
Lightwaves
@Lightwaves
Jun 25 2015 01:25
I think camper is better I'll stick with camper
Jessi L Wasell
@JessiW
Jun 25 2015 01:25
not sure why its not returning my 'c'?
Lightwaves
@Lightwaves
Jun 25 2015 01:25
I think it's because it skipped over c due to adding size to i
Jessi L Wasell
@JessiW
Jun 25 2015 01:26
sorry - if that camper is me :)
so should I just say size instead?
Lightwaves
@Lightwaves
Jun 25 2015 01:27
did you try it without the i+= size line?
Jessi L Wasell
@JessiW
Jun 25 2015 01:28
yes - now its returning a, b, b,c, c, d, d (in square brackets of course)
Matthew Kuo
@mattkuo
Jun 25 2015 01:31
@JessiW in your code you’re incrementing i two times
1st time you do i += size and then the for loop does i++
function chunk(arr, size) {
   var arrOne = [];
   var arrTwo = [];
 for (var i = 0; i<arr.length; i += size) {
   arrOne = arr.slice(i, i+size);
   arrTwo.push(arrOne);
 }
  return arrTwo;
}
try that but make sure you understand why that works ;)
Lightwaves
@Lightwaves
Jun 25 2015 01:32
/slaps head
that makes sense
I was having a bit of trouble geting both ends to jump up the amount of size I'm surprised I didn't think of that
Jessi L Wasell
@JessiW
Jun 25 2015 01:35
Okay - thanks @mattkuo - that worked! Not quite sure I understand why though?!:)
Lightwaves
@Lightwaves
Jun 25 2015 01:36
@JessiW slice grabs up to n-1
Mathieu Roy
@Mathieu-Roy
Jun 25 2015 01:37
It looks like I can't escape '<' and '>'. Any idea why?
function convert(str) {
  str = str.replace(/\&/g, "&amp;");
  str = str.replace(/</g, "&lt;");
  str = str.replace(/>/g, "&gt;");
  str = str.replace(/\'/g, "&quot;");
  str = str.replace(/\"/g, "&apos;");
  console.log(str);
  // &colon;&rpar;
  return str;
}

convert('<>');
Lightwaves
@Lightwaves
Jun 25 2015 01:37
0, 2
grabs from index 0,1
2,4 grabs from array indices 2,3
If you try grabbing from index 4 to n you've jumped past any value you could grab so it doesn't take anything
Matthew Kuo
@mattkuo
Jun 25 2015 01:39
@JessiW if you look at your code, at the end of the for loop you have i += size; immediately after that line is executed i++ is executed. So at the beginning of the 2nd loop i is equal to 3 instead of 2. Hope that helped...
Jessi L Wasell
@JessiW
Jun 25 2015 01:39
Okay - that makes sense - thanks @Lightwaves and @mattkuo :)
I'm copying our chat into Word for future reference - thank you both :)
Have a great night - its dinner time for me so I gotta go :+1:
Matthew Kuo
@mattkuo
Jun 25 2015 01:41
@JessiW night!
@Mathieu-Roy seems to be working for me
Mathieu Roy
@Mathieu-Roy
Jun 25 2015 01:44
@mattkuo oh strange :worried: ; thanks for the info; not sure what I should do then
adcor
@adcor
Jun 25 2015 02:08
Hey yall. Stuck again. Not sure how to iterate through so that my filter filters out all elements
function destroyer(arr) {
  var args = Array.prototype.slice.call(arguments);
  var arra = args[0];
  var argsPlus = args.filter(arrFilt);
  function arrFilt(value){
      return value !== args[0]; 
  }
  function realFilt(value){
      for(var i =0; i < arra.length; i++){
        if(argsPlus[i] !== ){}
      }
  }

  console.log(arra.length);
}
Moisés Man
@moigithub
Jun 25 2015 02:12
@adcor whats the test code ??? destroyer( .... ) arguments ?
adcor
@adcor
Jun 25 2015 02:12
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Moisés Man
@moigithub
Jun 25 2015 02:13
after run ur function... whats args value ?
adcor
@adcor
Jun 25 2015 02:15
args just gives me back all the values.
Moisés Man
@moigithub
Jun 25 2015 02:15
ahh .. its incomplete...
filter works like this....
[1,2,3,4,5].filter (function(value){ return value > 3}) ;
Alfonso Balsera Martinez
@AlfonB6
Jun 25 2015 02:17
need help
Moisés Man
@moigithub
Jun 25 2015 02:17
so.. filter pick each values on array... and pass to the internal function (callback ),, and IF evaluates true.. keeps the value
Alfonso Balsera Martinez
@AlfonB6
Jun 25 2015 02:17
function mutation (arr) { var mycase = arr[1].toLowerCase().split(''); var counter = 0; for (var i = 0; i < mycase.length; i++) { if (arr[0].indexOf(myCase[i]) >= 0) { counter ++ } } return counter === arr[1].length ? true: false } this is for bonfire mutations. get error with Army and Aarmy (i get false)
Moisés Man
@moigithub
Jun 25 2015 02:17

resulting in another array.. but with elements who meet the condition (on the example >3 )

[4,5] <-- result

adcor
@adcor
Jun 25 2015 02:19
i see, gonna have to read through this a couple times before it sinks in and I can ask a decent follow up question
Alfonso Balsera Martinez
@AlfonB6
Jun 25 2015 02:19
i try to split each character in arr1
Moisés Man
@moigithub
Jun 25 2015 02:19
@adcor
if args give u all values... then
arra = args[0]; will be [1,2,3,1,2,3]
Alfonso Balsera Martinez
@AlfonB6
Jun 25 2015 02:20
@adcor ['h','e','y'] is the new value of mycase
Moisés Man
@moigithub
Jun 25 2015 02:21
@adcor
and var argsPlus = args.filter(arrFilt);
will be like var argsPlus =[[1, 2, 3, 1, 2, 3], 2, 3].filter(arrFilt);
adcor
@adcor
Jun 25 2015 02:24
I haven't left, just thinking
Moisés Man
@moigithub
Jun 25 2015 02:25
@adcor
on that exercise.. whats asking ?? keep 2,3 or remove those values from array ??
[1, 2, 3, 1, 2, 3].filter(function(value){ console.log (value); }) <-- this will print each number
so inside ur callback u need to check IF its 2 or 3,, and return true to keep.. or false to reject
adcor
@adcor
Jun 25 2015 02:28
remove 2,3
okay
I guess where my question is the 2 and 3 are only for this instance. in other tests the number of arguments passed and the size of each may be different, in which case, how can I abstract those potential arguments such that I can filter for them
I guess is what I'm really asking
Alfonso Balsera Martinez
@AlfonB6
Jun 25 2015 02:36
hey guys
adcor
@adcor
Jun 25 2015 02:36
Hey Alfon sorry about the non responsiveness
can be hard to coordinate in a chatroom I gues
Alfonso Balsera Martinez
@AlfonB6
Jun 25 2015 02:37
how do i submit a message by hitting enter and not ctrl + enter?
Moisés Man
@moigithub
Jun 25 2015 02:37
@adcor
remember when i asked whats the value of args ?? :) console.log(args).. u will see ur "others" arguments there (2,3)
Alfonso Balsera Martinez
@AlfonB6
Jun 25 2015 02:37
@adcor no problem, i fixed it! i was missing a .toLowerCase();
got it
is the switch mode thing
Moisés Man
@moigithub
Jun 25 2015 02:40
and.. finished another zipline !! :) http://codepen.io/MMan/full/bdYKQB/
adcor
@adcor
Jun 25 2015 02:41
@moigithub congrats
Moisés Man
@moigithub
Jun 25 2015 02:41
ty :)
adcor
@adcor
Jun 25 2015 02:44
I'll get there some day
Brett Guillory
@kurzninja
Jun 25 2015 02:50
Anyone got any hints on doing the Pairwise bonfire? :D
Moisés Man
@moigithub
Jun 25 2015 02:53
i forgot whats pairwise :).. post the function test call
tjstinso
@tjstinso
Jun 25 2015 02:54
what have you tried so far?
Moisés Man
@moigithub
Jun 25 2015 02:55
im on ziplines already
Lightwaves
@Lightwaves
Jun 25 2015 02:55
I just did destroyer functionally my head hurts
Brett Guillory
@kurzninja
Jun 25 2015 02:55
I haven't tried anything yet, still trying to figure out how to approach it using the reduce function
pairwise([1,4,2,3,0,5], 7);
I'm not a big fan of the reduce function, it's confusing
Moisés Man
@moigithub
Jun 25 2015 02:56
[1,2,3,4,5].reduce(function(a,b){ console.log(a,b);} )
when u pass only 1 argument.. like that.. (callback function only )
Brett Guillory
@kurzninja
Jun 25 2015 02:57
right, but the callback has to be a little more complicated than that ;)
it's getting the callback right that's the challenge
Moisés Man
@moigithub
Jun 25 2015 02:57
a will be = 1 (first param)
b will be 2 (second argument )
Brett Guillory
@kurzninja
Jun 25 2015 02:57
right
i know how reduce() works
Moisés Man
@moigithub
Jun 25 2015 02:57
then it will iterate on all rest elements... so
whats the problem ? :D
Mathieu Roy
@Mathieu-Roy
Jun 25 2015 02:57
@moigithub good job for the zipline! how long did it took you?
Brett Guillory
@kurzninja
Jun 25 2015 02:58
i need to test multiple indices against each other, not just in order
Moisés Man
@moigithub
Jun 25 2015 02:58
almost all day... 8 hours.. with breaks.. a lot of breaks.. need to pull hair out.. n bang head against the wall to make it work :)
Mathieu Roy
@Mathieu-Roy
Jun 25 2015 02:58
@moigithub :)
Moisés Man
@moigithub
Jun 25 2015 02:59
wikipedia api has too many parameters.. hard to understand... after that was easy to call api n print results
and the bonus part i asked for hint too.. (first time asking ) autocomplete part
Justin Ceballos
@reliable-justin
Jun 25 2015 03:02
Whats the difference between increasing padding versus making margines more negative?
Mathieu Roy
@Mathieu-Roy
Jun 25 2015 03:02
@moigithub good to know (I'm trying to estimate how long it will take me before I finish everything; I'm not sure if the 800 hours is accurate)
Moisés Man
@moigithub
Jun 25 2015 03:03
@kurzninja
callback with 4 arguments
function test ( acumulator, element, index, array) { .... }
@Mathieu-Roy well some exercises are super easy.. and others not
zipline : Build a Random Quote Machine was easy.. no api needed
twitchTV (the first jquery api i did ) was a pain in the arse.. probably cuz no experience/ lack of knowledge (probably need a intro first/tutorials )
Mathieu Roy
@Mathieu-Roy
Jun 25 2015 03:09
@moigithub good to know; have you started from the beginning of FCC?
Moisés Man
@moigithub
Jun 25 2015 03:09
yep
i mean from the exercise num 1.. waypoints.. bonfires... n now ziplines
tjstinso
@tjstinso
Jun 25 2015 03:10
@kurzninja you could do arr.reduce(function(a,b) {arr.forEach(function(x) {//code in here } ) } )
Mathieu Roy
@Mathieu-Roy
Jun 25 2015 03:11
@moigithub about how long would you say it took you to reach where you are now?
Brett Guillory
@kurzninja
Jun 25 2015 03:11
I'll look into that @tjstinso
Moisés Man
@moigithub
Jun 25 2015 03:11
started 12-jun 10 hours /day ( have some previous knowledge ) been already on codeacademy /codeschool and other moocs
Rasheed Bustamam
@abustamam
Jun 25 2015 03:12
@reliable-justin going back to our box model, padding is the distance from the edge of the box to the content, and margin is the distance from the edge of the box to the edge of the next box
so making margins negative means that other boxes can go "into" the box, so to speak
Mathieu Roy
@Mathieu-Roy
Jun 25 2015 03:13
@moigithub wow, I started on June 12 myself, no kidding XD
@moigithub I'll soon do the Intermediate Algorithm Scripting bonfires.
Brett Guillory
@kurzninja
Jun 25 2015 03:14
hmmm, question about the array functions
the forEach() function has this in the documentation:
"The range of elements processed by forEach() is set before the first invocation of callback. "
does anyone know if the same holds true for reduce()?
Moisés Man
@moigithub
Jun 25 2015 03:15
@Mathieu-Roy probably u "play" less hours than me :sparkles:
Brett Guillory
@kurzninja
Jun 25 2015 03:15
I, personally, would expect so, but if NOT, then I might be able to use that
Mathieu Roy
@Mathieu-Roy
Jun 25 2015 03:16
@moigithub yes, but I'm trying to clear my schedule so I can do more. 10 hours a day would be great. :)
Moisés Man
@moigithub
Jun 25 2015 03:17
@Mathieu-Roy the last part of FUncional programming (Observables) was awfull pretty hard concepts to understand, i think i only understood 20% or so :)
Lightwaves
@Lightwaves
Jun 25 2015 03:17
@moigithub did you watch the video?
Moisés Man
@moigithub
Jun 25 2015 03:18
need to find some spanish tutorials probably
poor english here
Mathieu Roy
@Mathieu-Roy
Jun 25 2015 03:19
@moigithub wow, I'll try to understand at least 80% before moving on ^^
@moigithub did you get a certificate for completing all the bonfires?
Moisés Man
@moigithub
Jun 25 2015 03:20
dont know.. didnt read r heard about that
or*
well.. bedtime night :)
Mathieu Roy
@Mathieu-Roy
Jun 25 2015 03:22
@moigithub in this video, they say there's a certificate once all the bonfires are completed http://www.freecodecamp.com/challenges/waypoint-add-free-code-camp-to-your-linkedin-profile but I don't know how it works exactly to obtain it
@moigithub ok, good night!
tjstinso
@tjstinso
Jun 25 2015 03:38
ah man done with all my bonfires now, and time to review some html and css
rdm6789
@rdm6789
Jun 25 2015 03:39
Hi all, I had a question about the css portion for img resizing. should i ask that here or is there someother protocol/place ?
Zadious
@Zadious
Jun 25 2015 03:40
This is the appropriate room for help questions, yes. Ask away! :)
@tjstinso Awesome job completing the bonfires!
rdm6789
@rdm6789
Jun 25 2015 03:44

Thanks Zadious! I was able to resize the cat img we're using under 'size your image' but the box remains unchecked and not sure why? coded as follows > .smaller-image { width: 100px; }

</style>

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

<img class = smaller-image src ='https://bit.ly/fcc-kittens'/>

Freddy
@Lemony-Andrew
Jun 25 2015 03:44
@rdm6789 Image resizing? In css you effect an image's size manipulating the width and height variables. It depends on if you're working on an image that has been manipulated by something else if it has more problems than that. Or sometimes requires the parent element to be positioned and sized correclty.
@rdm6789 You didn't enclose the smaller-image class within ticks or quotes
take a look at your line <img class = smaller-image src ='https://bit.ly/fcc-kittens'/>
hint: attributes(such as id, class, value, and src) all require being enclosed within " "
rdm6789
@rdm6789
Jun 25 2015 03:46
ah ok will try it out, was confused because the img did actually change. thanks lemony-andrew.
Zadious
@Zadious
Jun 25 2015 03:47
sometimes the result will appear, but without the complete and proper code, the check mark will not appear.
rdm6789
@rdm6789
Jun 25 2015 03:49
thanks will play around with it
Erik W.
@PastorOfMuppets
Jun 25 2015 03:53
@denmch Just wanted to say thanks for the info on style sheets last night! I got pulled away before I could respond.
Den McHenry
@denmch
Jun 25 2015 05:31
@PastorOfMuppets Always happy to help, and I think there's room for improvement in how that stuff is introduced to new folks all over the web.
Adie Williams
@adieCodes
Jun 25 2015 05:38

Hi all. Just completed Seek and Destroy but a little confused by having to use an if/else loop rather than just if(arr[i] != arguments[1] || arguments[2])

I can't find any documentation that states you can only use one instance of arguments per conditional but is that the case?

Jordan Shackelford
@JordanShackelford
Jun 25 2015 05:46
Why can I not do arguments.foreach? If I want to do something based on the number of arguments, do I have to do for(var i = 0; i <arguments.length, i++)?
Eko Julianto Salim
@ekojsalim
Jun 25 2015 05:57
@JordanShackelford arguments is an array -like object, it doesn't have the built in methods of arrays
Elliescode
@EllieAdam
Jun 25 2015 05:57
Gnight!
Jordan Shackelford
@JordanShackelford
Jun 25 2015 05:58
So I have to copy all the arguments somewhere to be able to use that information?
Eko Julianto Salim
@ekojsalim
Jun 25 2015 05:59
@JordanShackelford Yes, you can use [].slice.call(arguments) to convert arguments into an array
Jordan Shackelford
@JordanShackelford
Jun 25 2015 05:59
If I have a number of array objects as arguments, how can I check the indexOf a value in each of those arguments?
Ok
What's the difference between call and apply?
Eko Julianto Salim
@ekojsalim
Jun 25 2015 06:00
@JordanShackelford You need a double loop there
Jordan Shackelford
@JordanShackelford
Jun 25 2015 06:00
I
I'm still trying to wrap my head around functional programming. I can probably solve this bonfire with for loops but I want to be able to do in the most functional way possible
Eko Julianto Salim
@ekojsalim
Jun 25 2015 06:01
@JordanShackelford call accepts arguments while apply accepts an array of arguments
@JordanShackelford two forEach can be useful
Which bonfire are you on?
Jordan Shackelford
@JordanShackelford
Jun 25 2015 06:02
but wouldn't you say using forEach is dysfunctional?
Symmetric difference. I've been stuck on it for a week lol. I think it was broken for a while
Eko Julianto Salim
@ekojsalim
Jun 25 2015 06:03
well, it wouldn't be in the functional programming waypoint if it is dysfunctional.
Jordan Shackelford
@JordanShackelford
Jun 25 2015 06:04
They said I can do just about anything with 5 methods: concat, filter, etc.
reduce
Eko Julianto Salim
@ekojsalim
Jun 25 2015 06:04
forEach , concatAll, filter , reduce and zip
Jordan Shackelford
@JordanShackelford
Jun 25 2015 06:05
yeah
Oh I guess foreach was included
concatAll doesn't seem to work for me though.
function sym(args) {
  var concatedArgs = [].reduce.call(arguments, function(a,b){
    return a.concat(b);
  });
  return concatedArgs.filter(function(value){
    //filter everything out that is not in all array arguments
  });
Eko Julianto Salim
@ekojsalim
Jun 25 2015 06:06
concatAll and zip are not built-in with javascript
Jordan Shackelford
@JordanShackelford
Jun 25 2015 06:07
ah so I'm going to have to rewrite those every time I need to use them? That doesn't seem very productive
Eko Julianto Salim
@ekojsalim
Jun 25 2015 06:08
or import a library, yes, you would have to rewrite them
Jordan Shackelford
@JordanShackelford
Jun 25 2015 06:08
Is it possible to implement, like, jQuery inside the bonfires? That would be crazy
Eko Julianto Salim
@ekojsalim
Jun 25 2015 06:09
hmm, why would you import jQuery for bonfires?
Jordan Shackelford
@JordanShackelford
Jun 25 2015 06:09
Not that I think it would be useful, but I think it would be cool if that was possible
Eko Julianto Salim
@ekojsalim
Jun 25 2015 06:09
terakilobyte has ramdajs integrated to fcc
you can use that for bonfires
Jordan Shackelford
@JordanShackelford
Jun 25 2015 06:10
That would be cheating right?
Like in the functional programming waypoints, we had to write the map and concatAll functions before we could use them
I think using a library before I completely understand the concepts would keep me from learning
Eko Julianto Salim
@ekojsalim
Jun 25 2015 06:12
Writing the methods is to familiarize the inner-working/concepts
You don't need to reinvent the wheel
terakilobyte used them in the bonfires :)
Jordan Shackelford
@JordanShackelford
Jun 25 2015 06:13
This intersection function looks useful
Eko Julianto Salim
@ekojsalim
Jun 25 2015 06:14
hmm yeah
Jordan Shackelford
@JordanShackelford
Jun 25 2015 06:17
Okay so If I do [].forEach.call(arguments)
That is copying all of the arguments into a new array?
Eko Julianto Salim
@ekojsalim
Jun 25 2015 06:19
no
forEach need a callback function there
you can just use slice
Jordan Shackelford
@JordanShackelford
Jun 25 2015 06:20
well I need to check the indexOf a value in each argument
Eko Julianto Salim
@ekojsalim
Jun 25 2015 06:21
[].slice(arguments), [].concat.call(arguments)
@JordanShackelford do var args = [].slice.call(arguments)
and do forEach other method on that args
Jordan Shackelford
@JordanShackelford
Jun 25 2015 06:22
Okay
Yeah that's exactly what I needed
Jordan Shackelford
@JordanShackelford
Jun 25 2015 06:29
function sym(args) {
  var argumentsCopy = [].slice.call(arguments);
  var concatedArgs = [].reduce.call(arguments, function(a,b){
    return a.concat(b);
  });
  return concatedArgs.filter(function(value){
    var allMatch = true;
    argumentsCopy.forEach(function(arg){
      if(arg.indexOf(value)===-1){
        allMatch = false;
      }
    });
    return !allMatch;
  });
}
This passes the first test
I know I really should be pair programming but it's hard to find someone on the same exercise as me in the same timezone
assert.deepEqual(sym([1, 2, 5], [2, 3, 5], [3, 4, 5]), [1, 4, 5], 'should return the symmetric difference of the given arrays');should return the symmetric difference of the given arrays: expected [ 1, 2, 2, 3, 3, 4 ] to deeply equal [ 1, 4, 5 ]
Jordan Shackelford
@JordanShackelford
Jun 25 2015 06:35
I don't understand how 5 is supposed to be part of the symmetric difference here when it's in every array arguments
Eko Julianto Salim
@ekojsalim
Jun 25 2015 06:40
five is included
Jordan Shackelford
@JordanShackelford
Jun 25 2015 06:40
I saw that one. Guess I need to rewatch it though :P
If the symmetric difference is all the numbers that are in one set but not all sets, how is 5 part of that? It's in every set
Eko Julianto Salim
@ekojsalim
Jun 25 2015 06:44
This message was deleted
hmm, wrong image
Jordan Shackelford
@JordanShackelford
Jun 25 2015 06:45
lel
Eko Julianto Salim
@ekojsalim
Jun 25 2015 06:45
@JordanShackelford yeah it's in every set, that's why
Jordan Shackelford
@JordanShackelford
Jun 25 2015 06:48
They need to give it a different name or something
'symmetric difference' gives the wrong idea
Eko Julianto Salim
@ekojsalim
Jun 25 2015 06:50
yeah, it can be confusing
Jordan Shackelford
@JordanShackelford
Jun 25 2015 06:53
So basically I need to find the numbers that are in one set or all sets
If there are 3 sets, each number in the symmetric difference will be in either 1 set or 3 sets, but not 2
Mathieu Roy
@Mathieu-Roy
Jun 25 2015 06:58
I just did the Roman Numeral Converter bonfire. I'm wondering if anyone else has come with something more elegant than me. My Ruby version is cleaner than my JS one. Can I share my solution here?
Jordan Shackelford
@JordanShackelford
Jun 25 2015 07:01
@Mathieu-Roy yeah
Mathieu Roy
@Mathieu-Roy
Jun 25 2015 07:02
@JordanShackelford
// by mathieu_roy
function convert(num) {
  console.log(num);
  var roman = "";
  function part(a, b, c, f) {
    big = Math.floor(num/(10*f));
    for(var i=0; i < big; i++) roman += a;
    num -= big*10*f; console.log(num);
    if(num >= 9*f){
      roman += c + a;
      num -= 9*f;
    } else if(num >= 5*f) {
      roman += b;
      num -= 5*f;
    } else if(num >= 4*f) {
      roman += c + b;
      num -= 4*f;
    }
    console.log(num);
    small = Math.floor(num/f);
    for(var j=0; j < small; j++) roman += c;
    num -= small*f; console.log(num);
    return roman;
  }
  roman = part("M", "D", "C", 100);
  roman = part("C", "L", "X", 10);
  roman = part("X", "V", "I", 1);
  return roman;
}

convert(9);
Rasheed Bustamam
@abustamam
Jun 25 2015 07:04
I used objects
Jordan Shackelford
@JordanShackelford
Jun 25 2015 07:05
Yeah that looks too complicated.
Rasheed Bustamam
@abustamam
Jun 25 2015 07:05
function convert(num) {
  var roms = {10: 'X',
              9: 'IX',
              5: 'V',
              4: 'IV',
              1: 'I'};
  var keys = Object.keys(roms);

  var res = "";

  for (var i = keys.length-1; i >= 0; i--){
    var key = keys[i];
    var val = roms[key];
    while (num >= key){
      res += val;
      num -= key;
    }
  }


  return res;
}

convert(36);
Jordan Shackelford
@JordanShackelford
Jun 25 2015 07:06
That 9 = IX thing seemed so awesome to me. It blew my mind
I did that same thing
Rasheed Bustamam
@abustamam
Jun 25 2015 07:06
haha. how so?
Mathieu Roy
@Mathieu-Roy
Jun 25 2015 07:07
@abustamam oh, that's way more elegant! thanks for sharing! It should be easy to extend this program to include the M, D, C, L letters
Jordan Shackelford
@JordanShackelford
Jun 25 2015 07:07
I don't think you need 4 = IV though. Or atleast I didn't
The only number I really needed to invent a new character for was 9
Rasheed Bustamam
@abustamam
Jun 25 2015 07:11
@Mathieu-Roy yep! easily extendable. i kinda cheated tho because i've done this problem before in python :D
@JordanShackelford hm i'm curious; how'd you make do w/o 4 = iv?
Jordan Shackelford
@JordanShackelford
Jun 25 2015 07:11
This was my solutino
function convert(num) {

 var romanString = '';
 var numeralObject = {1000:'M',500:'D',100:'C',50:'L',10:'X', 9:'IX',5:'V', 1:'I'};
 var sortedNumerals = Object.keys(numeralObject).sort(function(a,b){
   return b - a;
 });
 var leftover = num;

  for(i = 0; i < sortedNumerals.length; i++){
    while(leftover >= sortedNumerals[i]){
      romanString += numeralObject[sortedNumerals[i]];
      leftover -= sortedNumerals[i];
    }
  }
  return romanString;
}
convert(36);
Mathieu Roy
@Mathieu-Roy
Jun 25 2015 07:12

@abustamam I would have been tempted to code:

for (var i = keys.length-1; i >= 0; i--){
    while (num >= keys[i]){
      res += roms[keys[i]];
      num -= keys[i];
    }
  }

I have no experience in writing clean code. Do you think your version is better?

@JordanShackelford test convert(4) to see
Rasheed Bustamam
@abustamam
Jun 25 2015 07:13
@Mathieu-Roy yours works fine! fewer variables :)
Mathieu Roy
@Mathieu-Roy
Jun 25 2015 07:13
@abustamam allright, thanks ^^
Jordan Shackelford
@JordanShackelford
Jun 25 2015 07:13
convert(4) gives me IIII lol. but it still passed all the tests
Rasheed Bustamam
@abustamam
Jun 25 2015 07:14
haha. actually, in older roman numerals (as if they weren't old enough) 4 was iiii
and 9 was viiii
at least that's what my grandfather clock says
Jordan Shackelford
@JordanShackelford
Jun 25 2015 07:14
Whoever made your clock doesn't know numerals lol :P
Idk. I'm just glad we don't use those anymore
Rasheed Bustamam
@abustamam
Jun 25 2015 07:16
hahah
imagine calculus using roman numerals
Mathieu Roy
@Mathieu-Roy
Jun 25 2015 07:16
@abustamam haha XD
"Roman inscriptions, especially in official contexts, seem to show a preference for additive forms such as IIII and VIIII instead of (or even as well as) subtractive forms such as IV and IX. Both methods appear in documents from the Roman era, even within the same document. "Double subtractives" also occur, such as XIIX or even IIXX instead of XVIII. Sometimes V and L are not used, with instances such as IIIIII and XXXXXX rather than VI or LX" https://en.wikipedia.org/wiki/Roman_numerals
say what ^^
Rasheed Bustamam
@abustamam
Jun 25 2015 07:17
my life is a lie
Mathieu Roy
@Mathieu-Roy
Jun 25 2015 07:17
XD
Douglas Mitchell
@MitchDoogle
Jun 25 2015 09:19
I'm having trouble with JavaScript algorithm bonfire: Convert HTML Entities. My code appears to be working, I passed in the string "&<>\'\"" and all five characters display the html code in the console
Krzysztof Miąsko
@kmiasko
Jun 25 2015 10:09
it's bugged, leave it for now
completing task 1 doesn't advance you in the course
Nathan
@terakilobyte
Jun 25 2015 11:22
unfortunately the discover devtools course is a bit buggy
I remember there were some that I just had to skip
Jordan Shackelford
@JordanShackelford
Jun 25 2015 11:35
this summer heat is killing me. makes it hard to focus
jgadjiev
@jgadjiev
Jun 25 2015 11:41
Could anyone tell me what I'm doing wrong in the Make A Person bonfire. It passes all the tests except the last three.
blob
Rasheed Bustamam
@abustamam
Jun 25 2015 11:53
FCC is not working for me but from what I can tell, this.setFirstName() is not updating the first name to be first
same w/ setLastName
and setFullName
jgadjiev
@jgadjiev
Jun 25 2015 11:58
what would I have to do for it to update it ?
ronaldrdguez
@ronaldrdguez
Jun 25 2015 11:59
@jgadjiev I think you need to keep first, last, and firstAndLast in sync, if you set lets say first, you also need to update firstAndLast. I got it to pass by using just firstAndLast for everything. Like this...
this.setFirstName = function(first) {
    firstAndLast = first + ' ' + firstAndLast.split(' ')[1];
  };

  this.setLastName = function(last) {
    firstAndLast = firstAndLast.split(' ')[0] + ' ' + last;
  };

  this.setFullName = function(firstAndLast) {
    this.setFirstName(firstAndLast.split(' ')[0]);
    this.setLastName(firstAndLast.split(' ')[1]);
  };
jgadjiev
@jgadjiev
Jun 25 2015 12:10
Yeah, that does work
BaLin
@Kinderspiel86
Jun 25 2015 12:58
hey guys Im really at the beginning..
could you tell me how to implement the 'Lobster-style'??

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

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

<h2 class='red-text'>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>

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

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

<h2 class='red-text'>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>

sooryi dont wanted to spam..
Ryan Malm
@Rybar
Jun 25 2015 13:22
when posting code, start with three backticks ( ` ) <-next to 1 on US keyboards, then enter, then paste your code, then three more backticks.
```
<p> shows like this. </p>
Did you look at the 'more info' section of that exercise?
EngineeredEdge
@EngineeredEdge
Jun 25 2015 13:35
hola Free Code Camp
Ryan Malm
@Rybar
Jun 25 2015 13:40
Hi @EngineeredEdge
EngineeredEdge
@EngineeredEdge
Jun 25 2015 13:41
Rybar, how far along are you with FreeCodeCamp
Evan Davis
@davisec52
Jun 25 2015 13:41

I have been trying to get a better understanding
of closure, scope, and private variables. Douglas
Crockford explains private variables at
http://javascript.crockford.com/private.html.

However, the example he gives does not appear to
work as explained, and I'm hoping someone here
can clarify the problem for me.

The issue is that in the code below, var secret does
not appear to decrement. I'm guessing that var secret
re-initializes every time the function is called, but
I don't really know.

The expected result is that myContainer.service() should
return 'abc' while secret > 0. When you actually run
the code below (which you can find at the link above),
secret does not decrement and does not return null.

Anyone have any idea why and how to fix it?


function Container(param) {

    function dec() {
       if(secret > 0){
           secret -= 1;
           return true;
       }else
       {
           return false;

       }
    }

    this.member = param;
    var secret = 3;
    var that = this;

    this.service = function () {
        return dec() ? that.member : null;
    };
}

var myContainer = new Container('abc');

myContainer.service();
EngineeredEdge
@EngineeredEdge
Jun 25 2015 13:45
@davisec52 run myContainer.service() a few more times
you will notice it stops returning
=> 'abc'
myContainer.service()
=> 'abc'
myContainer.service()
=> 'abc'
myContainer.service()
=> null
myContainer.service()
=> null
myContainer.service()
=> null
aside, how do we post code / output in a clean / pretty fashion?
Evan Davis
@davisec52
Jun 25 2015 13:47
@EngineeredEdge Hi. When I run it in repl.it, it never returns null.
EngineeredEdge
@EngineeredEdge
Jun 25 2015 13:47
are you rerunning that code?
Evan Davis
@davisec52
Jun 25 2015 13:47
yes
EngineeredEdge
@EngineeredEdge
Jun 25 2015 13:47
well then you are creating a new object every time
Michael D. Johnson
@CodeNonprofit
Jun 25 2015 13:47
@EngineeredEdge You can use three ticks before and after the code you’re pasting, like so: ```
EngineeredEdge
@EngineeredEdge
Jun 25 2015 13:47
go tot he command line
and type myContainer.service()
on repl.it, the command line is hte right half of the page
thank you @CodeNonprofit
or, just add more calls at the end of your page

'''
function Container(param) {

function dec() {
   if(secret > 0){
       secret -= 1;
       return true;
   }else
   {
       return false;

   }
}

this.member = param;
var secret = 3;
var that = this;

this.service = function () {
    return dec() ? that.member : null;
};

}

var myContainer = new Container('abc');

console.log(myContainer.service());
console.log(myContainer.service());
console.log(myContainer.service());
console.log(myContainer.service());
console.log(myContainer.service());
console.log(myContainer.service());

ermmmm
not sure why it cuts out like that
Evan Davis
@davisec52
Jun 25 2015 13:51
@EngineeredEdge Right. I ran it in the chrome console and it was easier to see it returning
Many thanks!
EngineeredEdge
@EngineeredEdge
Jun 25 2015 13:53
'''

'''
function Container(param) {

function dec() {
   if(secret > 0){
       secret -= 1;
       return true;
   }else
   {
       return false;

   }
}

this.member = param;
var secret = 3;
var that = this;

this.service = function () {
    return dec() ? that.member : null;
};

}

var myContainer = new Container('abc');

console.log(myContainer.service());
console.log(myContainer.service());
console.log(myContainer.service());
console.log(myContainer.service());
console.log(myContainer.service());
console.log(myContainer.service());'''

lol I can not get this to work

'''
function Container(param) {

function dec() {
   if(secret > 0){
       secret -= 1;
       return true;
   }else
   {
       return false;

   }
}

this.member = param;
var secret = 3;
var that = this;

this.service = function () {
    return dec() ? that.member : null;
};

}

var myContainer = new Container('abc');

console.log(myContainer.service());
console.log(myContainer.service());
console.log(myContainer.service());
console.log(myContainer.service());
console.log(myContainer.service());
console.log(myContainer.service()); '''

:::::::::::::::::::::::::::::::::::
sorry for blowing up your feed, not sure what i'm doing wrong
Steven Leiva
@StevenXL
Jun 25 2015 13:56
Hi. For the first zipline - Twitch.tv API - are we supposed to be using frameworks such as Angular?
Or do we build it up by hand?
Evan Davis
@davisec52
Jun 25 2015 13:56
@EngineeredEdge console.log(myContainer.service()); returns a result for me.
EngineeredEdge
@EngineeredEdge
Jun 25 2015 13:57
@davisec52 it should return a result. THe first thre times it should return, 'abc'
@StevenXL I am also on that first zipline, I believe we should just do it by hand and then return to it after we learn angular
BUT, obviously if you know angular then you can do it now
@StevenXL I was having trouble with the TWITCH API call, did you have any success with that?
Eko Julianto Salim
@ekojsalim
Jun 25 2015 13:59
@StevenXL you can use whatever framework or library you need or want to use
EngineeredEdge
@EngineeredEdge
Jun 25 2015 13:59
@davisec52 the entire point of hte decrement is that it will llos the .service() method to be used 3 times before returning it returns NULL
Eko Julianto Salim
@ekojsalim
Jun 25 2015 14:00
@StevenXL if you want to go the hardcore route using vanilla javascript, you can do it :)
EngineeredEdge
@EngineeredEdge
Jun 25 2015 14:02
Is there a way to run jQuery commands on repl.it?
Moisés Man
@moigithub
Jun 25 2015 14:04
import it first... with script tag ?
Evan Davis
@davisec52
Jun 25 2015 14:05
@EngineeredEdge I understand that. When I was running the code earlier, it was not returning null. The reason, as you suggested, is that I was reinitializing the function each time I called it. When I wrote all of the function calls before returning, the code gave the expected result.
Steven Leiva
@StevenXL
Jun 25 2015 14:05
I think I'll stick with jQuery. Thanks guys!
EngineeredEdge
@EngineeredEdge
Jun 25 2015 14:06
@moigithub the script tag is html, right?
@StevenXL have you had any success working with the twitch api?
Moisés Man
@moigithub
Jun 25 2015 14:14
EngineeredEdge
@EngineeredEdge
Jun 25 2015 14:18
@moigithub sorry if I wasn't clear, I meant is there a way to run jquery commans on repl.it while in the javascript environment
but I guess I could justwork in an html environment
Eko Julianto Salim
@ekojsalim
Jun 25 2015 14:19
@EngineeredEdge I am not sure about repl.it , if you want to show demos about jquery, you can go to jsfiddle or plnkr.co
EngineeredEdge
@EngineeredEdge
Jun 25 2015 14:20
@ekojsalim gracias
Also just found the error I was having
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.twitch.tv/kraken/streams/test_channel. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
Eko Julianto Salim
@ekojsalim
Jun 25 2015 14:24
@EngineeredEdge ah make sure you are sending a jsonp request
evaristoc
@evaristoc
Jun 25 2015 14:29
Hello everyone here! Someone with some experience with Angular in Node using socket.io?
EngineeredEdge
@EngineeredEdge
Jun 25 2015 14:32
@ekojsalim like ''' $.ajax({dataType: "jsonp",
url: 'https://api.twitch.tv/kraken/streams/test_channel'})
::::::::::::::;, i really can not figure out how to pretty-paste
'''$.ajax({dataType: "jsonp",
url: 'https://api.twitch.tv/kraken/streams/test_channel'})'''
''' $.ajax({dataType: "jsonp",
url: 'https://api.twitch.tv/kraken/streams/test_channel'}) '''
Eko Julianto Salim
@ekojsalim
Jun 25 2015 14:33
use the backticks `
Michael D. Johnson
@CodeNonprofit
Jun 25 2015 14:33
` != '
EngineeredEdge
@EngineeredEdge
Jun 25 2015 14:33
$.ajax({dataType: "jsonp", url: 'https://api.twitch.tv/kraken/streams/test_channel'})
!
gracias
Michael D. Johnson
@CodeNonprofit
Jun 25 2015 14:33
top left of your keyboard in all likelihood
EngineeredEdge
@EngineeredEdge
Jun 25 2015 14:34
gracias gracias
and now i'm in business, because that works
Eko Julianto Salim
@ekojsalim
Jun 25 2015 14:34
@EngineeredEdge hmm yeah, the should be it
TopEgret
@topegret
Jun 25 2015 14:35
Any one have clue on BoreFone 16? Where art thou ...
I even don't know how to start to work with this challenge
EngineeredEdge
@EngineeredEdge
Jun 25 2015 14:37
specify how fonts should degrade?
Nic Galluzzo
@ngalluzzo
Jun 25 2015 14:39
@topegret it’s definetely a tricky one but you should be able to get it :)
EngineeredEdge
@EngineeredEdge
Jun 25 2015 14:40
I suggest creating a helper function inside of th emain function
that tests if an object in collection is a match to the source
TopEgret
@topegret
Jun 25 2015 14:44
@ngalluzzo seems the knowledge of JS Object concept is the key. but does FCC introduce the Object in previous tutorial? to me, JS is language is rather sloppy than other languages.:-)
Nic Galluzzo
@ngalluzzo
Jun 25 2015 14:44
sure did, taught us about Object.keys
Stjepan Mazalovic
@stjema
Jun 25 2015 15:03
gm'morning :P
Howard-S
@Howard-S
Jun 25 2015 15:39
Hello all
I'm stuck on an assignment - anyone feel like helping a newbie?
EngineeredEdge
@EngineeredEdge
Jun 25 2015 15:51
which assignment
adcor
@adcor
Jun 25 2015 15:55
can someone explain to me why my code works .This is for seek and destroy bonfire.
I would have though in the realFilt, that setting the if statement to not equal only the first two arguments, that it wouldn't cover a greater number of arguments.
function destroyer(arr) {
   var args = Array.prototype.slice.call(arguments);
   var arra = args[0];
   var argsPlus = args.filter(arrFilt);
   function arrFilt(value){
       return value !== args[0]; 
   }
   function realFilt(value, index, array){
       for(var i = 0; i < argsPlus.length; i++){
           if(value !== argsPlus[0] && value !== argsPlus[1]){
               return value;
           }
       }
   }


   return arra.filter(realFilt);
 }
Howard-S
@Howard-S
Jun 25 2015 15:58
@EngineeredEdge Waypoint: Give a Background Color to a Div Element
EngineeredEdge
@EngineeredEdge
Jun 25 2015 15:59
@adcor the argsPlus is a convoluted way to remove the first element from an array
Howard-S
@Howard-S
Jun 25 2015 15:59

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

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

h2 {
font-family: Lobster, Monospace;
}

p {
font-size: 16px;
font-family: Monospace;
}

.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}

.smaller-image {
width: 100px;
}
</style>

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

<p>Click here for <a href='#'>cat photos</a>.</p>

<a href='#'><img class='smaller-image thick-green-border' src='https://bit.ly/fcc-kittens'/></a>

<div>
<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>

<form action="/submit-cat-photo">
<label><input type='radio' name='indoor-outdoor' checked> Indoor</label>
<label><input type='radio' name='indoor-outdoor'> Outdoor</label>
<br>
<label><input type='checkbox' name='personality' checked> Loving</label>
<label><input type='checkbox' name='personality'> Lazy</label>
<label><input type='checkbox' name='personality'> Energetic</label>
<br>
<input type='text' placeholder='cat photo URL' required>
<button type='submit'>Submit</button>
</form>

Where does this go? For example, if you wanted an element's background color to be "green", you'd use .green-background { background-color: green; } within your style element.
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:00
var argsPlus2 = args.slice(1);
console.log(argsPlus === argsPluse2);
Yes
@Howard-S the code between <style> </style> is hwere the CSS classes go
Howard-S
@Howard-S
Jun 25 2015 16:03
@EngineeredEdge i tried to put it there but I guess I didnt get the prefix correct. You couldnt just add that line as-is, correct?
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:03
::::::::::::::
@howard, follow the steps. Did you succesfully give your <div> the appropriate class?
adcor
@adcor
Jun 25 2015 16:05
@EngineeredEdge argsPlus is used to abstract and seperate from all arguments a variable amount of arguments that will then be filtered from the first argument. I added your code, came back false
Howard-S
@Howard-S
Jun 25 2015 16:05
i think so
adcor
@adcor
Jun 25 2015 16:05
I agree my code is convoluted though. Not sure how to simplify
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:05
@Howard-S below the instructions there is a checkbox, is the first step GREEN or RED?
@adcor could you send me the call you made that came back false?
Howard-S
@Howard-S
Jun 25 2015 16:06
red, so its not correct
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:06
Read the instructiosn carefully
I think you are misreading 'gray' as 'green'
adcor
@adcor
Jun 25 2015 16:07
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Howard-S
@Howard-S
Jun 25 2015 16:08
i'll re-read and check back w u
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:09
@adcor that is interesting. replace that console.log with
console.log(argsPlus,argsPlus2,argsPlus===argsPlus2);
adcor
@adcor
Jun 25 2015 16:12
this is what came back
[2, 3] [2, 3] false
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:13
@adcor as you can see, javascript has some weird equality stuff with objects
you and i would think [2,3] === [2,3] to return true
but that's not how javascript works. It returns false because they are two different objects in memory. Here is an explanation: http://adripofjavascript.com/blog/drips/object-equality-in-javascript.html
but for your case, you can see that they are equivalent
adcor
@adcor
Jun 25 2015 16:15
interesting
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:15
so, remove the convoluted way and replace with args.slice(1)
adcor
@adcor
Jun 25 2015 16:16
I just ran the new code. Worked
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:17
now, the second thing you just taught me was that the callBack function for .filter() CAN take three arguments
"""
callback
Function to test each element of the array. Invoked with arguments (element, index, array). Return true to keep the element, false otherwise.
"""
you can see that, here
NOTE: you can just pass the element/value and ignore index/array
Now, your real logic is poor
for instance, what is the loop doing there? i don't see i mentioned anywhere outside the foor loop definition
second, your logic only works when we are trying to filter out two values, argsPlus[0] and argsPlus1
adcor
@adcor
Jun 25 2015 16:21
yeah, that was my next question
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:21
@Howard-S did you figure it out?
Howard-S
@Howard-S
Jun 25 2015 16:21
@EngineeredEdge no, i was searching the web too. its just not clicking...
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:21
have you accomplished step 1?
@adcor you have your array that you want to filter (arra) and you have the items you'd like to filter out (argsPlus), can you explain in words what you would like to do next to arrive at the result?
@Howard-S - do you know how to add a class to an HTML element?
Moisés Man
@moigithub
Jun 25 2015 16:23
any1 have a base64 audio file.. like a beep ring or alarm ?
Howard-S
@Howard-S
Jun 25 2015 16:23
thats where i think im stuck
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:24
can you explain in english what the question is asking you to do?
@moigithub sorry I do not.
Howard-S
@Howard-S
Jun 25 2015 16:25
my div class needs to have a gray background
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:26
@Howard-S sorry I got confused beween you and adcor for a second. Where you are stuck is figuring out how to add a class to an HTML element, correct?
Howard-S
@Howard-S
Jun 25 2015 16:26
so < div class="gray background">
@EngineeredEdge thats one step, yes
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:27
is that the class they are asking you to add?
adcor
@adcor
Jun 25 2015 16:27
@EngineeredEdge If argsPlus is in arra, then remove argsPlus, my problem was how do I loop through the elements in argsPlus such that when an element of arra is passed to it, it checks for those elements.
Howard-S
@Howard-S
Jun 25 2015 16:28
I'll wait til you are clear with helping adcor -
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:28
@Howard-S please re-read Step1 and take alook at the class you added. That is the correct way to add a class, you added the wrong one.
@adcor argsPlus is an array of items, do you mean tha tif arra contains an entire arary of items, then remove that entire array?
Howard-S
@Howard-S
Jun 25 2015 16:29
@EngineeredEdge got step one done - now for 2. thanks for the help btw
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:29
@Howard-S now re-read the instructions, it contains exactly the information you need to know, except for adding 'green-background'
Howard-S
@Howard-S
Jun 25 2015 16:30
ok
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:30
@adcor [note: I know what you really mean because I am a human. I'm asking you to express it more specifically so it's closer to the instruction you need to give to the computer]
adcor
@adcor
Jun 25 2015 16:32
I mean what I'd like to do is I'd like to use filter on arra, and then compare that element to the first element in argsPlus, then if those elements are equal, remove that element, If they aren't equal, move to the next element in argsPlus to see if they are equal until all elements in argsPlus have been checked
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:33
Are you familiar with how the .filter() function works? you did use it twice in your original code
::::::::::::::
or are you familiar with nested for loops?
Howard-S
@Howard-S
Jun 25 2015 16:35
@EngineeredEdge took forever - i guess im tired - thanks for the help
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:35
@Howard-S you passed?
Howard-S
@Howard-S
Jun 25 2015 16:36
yes - for some reason i thought the whole string of code was needed for both steps. wasnt the case
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:37
hmmm, that is not the case. Do you understand why? what is the function of CSS ?
adcor
@adcor
Jun 25 2015 16:37
I don't think I'm familiar with nested for loops. I know filter passes each element of an array into a function that checks for a condition and then creates a new array of elements that meet that condition.
correct?
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:38
very good yes.
Howard-S
@Howard-S
Jun 25 2015 16:38
@EngineeredEdge it is odd to me that if the css calls for gray, why is there a need for it again in the div class
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:39
hmmm you notice that there are a handful of CSS classes right? 'thick-green-border'
'smaller-image'
'red-text'
Howard-S
@Howard-S
Jun 25 2015 16:40
yes
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:40
Are all of those applied to every html element?
Howard-S
@Howard-S
Jun 25 2015 16:40
yes
no
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:41
so!!!???
Ariel
@ArielLeslie
Jun 25 2015 16:41
@adcor "nested loops" is just a loop inside another loop.
for every house in the city
for every dog in that house
pet the dog
Howard-S
@Howard-S
Jun 25 2015 16:41
so its almost like an "override"?
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:41
nope
what elements are the 'thick-green-border' applied to?
Howard-S
@Howard-S
Jun 25 2015 16:42
i advanced the page but I think it was the photo
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:42
@adcor you are very close to the answer. if I asked you to write a function that checks whether a single item is contained in an array and returns true or false, could you do that?
@Howard-S don't move on! this is critical to understanding CSS / HTML
sowpat
@sowpat
Jun 25 2015 16:43
Hey guys, so I am on the "find the longest word in a string" bonfire, where when given a string you have to return the length of the longest word in that string. For some reason my code is not working, can anyone explain why:

function findLongestWord(str) {
var string = str.split(' ');
var max = 0;
var length = 0;
for(var i = 0; i < string.length; i++){
length = (string[i]).length;
if (max < length){
max = length;
}
}
return length;
}

findLongestWord('The quick brown fox jumped over the lazy dog');

This is my code ^^^
Ariel
@ArielLeslie
Jun 25 2015 16:44
in what way is it "not working"?
sowpat
@sowpat
Jun 25 2015 16:44
it always returns the wrong number
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:45
@sowpat include ``` before and after your code (tildes, NOT single quotes)
so that it pastes properly
Howard-S
@Howard-S
Jun 25 2015 16:45
@EngineeredEdge went back - thick green is the photo border, in CSS
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:45

``` function findLongestWord(str) {
var string = str.split(' ');
var max = 0;
var length = 0;
for(var i = 0; i < string.length; i++){
length = (string[i]).length;
if (max < length){
max = length;
}
}
return length;
}

findLongestWord('The quick brown fox jumped over the lazy dog');
```

function findLongestWord(str) {
var string = str.split(' ');
var max = 0;
var length = 0;
for(var i = 0; i < string.length; i++){
length = (string[i]).length;
if (max < length){
max = length;
}
}
return length;
}

findLongestWord('The quick brown fox jumped over the lazy dog');
sowpat
@sowpat
Jun 25 2015 16:46
Oh okay I will next time, sorry I am new to this chat
Ariel
@ArielLeslie
Jun 25 2015 16:46
you want to return max, not length
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:46
i just learned it today
sowpat
@sowpat
Jun 25 2015 16:46
oh yeah! Thanks so much :)
Ariel
@ArielLeslie
Jun 25 2015 16:46
no worries
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:46
@Howard-S so why did we need to define class='gray-background' in the div element?
Howard-S
@Howard-S
Jun 25 2015 16:49
no clue
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:50
!!!
take alook at the image element again, tell me why thick-green-border showed up for that element but no other elements
Howard-S
@Howard-S
Jun 25 2015 16:50
its assigned to it specifically
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:50
!
what's the difference between that and the gray-background class?
Howard-S
@Howard-S
Jun 25 2015 16:51
assigned to it specifically too i guess
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:51
!
The CSS is not applied to every elements
it's only applied to elements that it matches to
Howard-S
@Howard-S
Jun 25 2015 16:52
but html is?
oh i see.
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:52
i'm not sure what you mean
CSS has selectors. the '.' is the 'class selector'
so for every element that has a certain class
that CSS will be applied
Howard-S
@Howard-S
Jun 25 2015 16:52
i got you thats why there is a prefix of ex. p { etc
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:53
RIGHT! the p is applied to every <p> element
the h1 is applied to every <h1> element
Howard-S
@Howard-S
Jun 25 2015 16:53
gotcha - i understand
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:53
there are other selectors to that you will learn about later
Howard-S
@Howard-S
Jun 25 2015 16:53
thanks for the help. i thought of it as redundant
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:54
right, which was critically incorrect
Howard-S
@Howard-S
Jun 25 2015 16:54
i see that now
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:54
or, they are critically NOT redundant
@adcor did you get it?
Howard-S
@Howard-S
Jun 25 2015 16:55
thanks again.
adcor
@adcor
Jun 25 2015 16:55
@EngineeredEdge here's what I wrote
```
function checky(somNum){
    var check = [1, 2, 3, 4];
    function filt(){
        for(var i = 0; i < check.length; i++){
            if(check[i] === somNum){
                return true;
            }
        }
    }  

}
EngineeredEdge
@EngineeredEdge
Jun 25 2015 16:56
@Howard-S you're welcome
@adcor when does that function return true, and when do you want your filter function to return true
also what is the need for the secondary function
adcor
@adcor
Jun 25 2015 16:59
yeah, I meant to put this
function checky(somNum){
    var check = [1, 2, 3, 4];
    function filt(){
        for(var i = 0; i < check.length; i++){
            if(check[i] === somNum){
                console.log(true);
            }
        }
    }  
    console.log(check.filter(filt));
}
it returns true if somNum is in check, return nothing if it isn't
technically it console.logs it in this version
EngineeredEdge
@EngineeredEdge
Jun 25 2015 17:02
"I don't think I'm familiar with nested for loops. I know filter passes each element of an array into a function that checks for a condition and then creates a new array of elements that meet that condition.
correct?"
so [1,2,3,4].filter(checky) would take the first element, 1, and call checky(1), if that returns true then the element is kept
adcor
@adcor
Jun 25 2015 17:06
that's not what happens though, it returns the entire array
because, it doesn't return the value, it just returns true. it isn't really working as a filter
gotcha
EngineeredEdge
@EngineeredEdge
Jun 25 2015 17:07
:D
try [3,4,5,6].filter(checky)
and again, checky as is isn't written correctly
myronb
@myronb
Jun 25 2015 17:09
I'm getting massively stuck with functional programming in the advanced algorithms. Given that my goal is to become a solid front end dev, I'd like to know if this is necessary to conquer?
advanced bonfires*
adcor
@adcor
Jun 25 2015 17:09
This is what I got. What am I doing wrong in terms of writing it
function checky(somNum){
    var check = [1, 2, 3, 4];
    function filt(value){
        for(var i = 0; i < check.length; i++){
            if(value === somNum){
                return true;
            }
        }
    }  
    console.log([3,4,5,6].filter(filt));
}
oh, hold on
Ariel
@ArielLeslie
Jun 25 2015 17:11
@myronb The MOST important skill of a dev is problem solving, so even if you never need to do a lot of complex functional programming (and I'm not saying you won't), you should build those algorithmic problem-solving muscles
adcor
@adcor
Jun 25 2015 17:13
function checky(somNum){
    var check = [1, 2, 3, 4];
    function filt(value){
            if(value === somNum){
                return true;
            }

    }  
    console.log([3,4,5,6].filter(filt));
}
EngineeredEdge
@EngineeredEdge
Jun 25 2015 17:15
.............
@adcor i'm asking you to right the function that you will PASS into filter
so you shouldn't be using .filter in the function
myronb
@myronb
Jun 25 2015 17:16

@arielleslie thank you. My plan is to keep going with them. At the same time, I'd like to know how much of this is relevant to front end dev, i.e. should I start applying for front end jobs before I master these, since FCC curriculum is geared toward full-stack?

I think Hack Reactor said, for front end devs concepts like closures aren't as important. So trying to see where to draw the imaginary line.

EngineeredEdge
@EngineeredEdge
Jun 25 2015 17:20
function checky(someNum) {
    var targets = [1,2,3,4];

    for (i=1;i<targets.length;i++) {
        if (targets[i]===someNum) {
            return true;
        }
    }
    return false;
}

[3,4,5,6].filter(checky);
@adcor the ^^^ isn't your entire answer, but it should clarify how filter works
adcor
@adcor
Jun 25 2015 17:25
it all makes sense now
:p
ugh, that's obnoxious, anyway, it doesn't all make sense, need to ruminate for a bit before it sinks in
EngineeredEdge
@EngineeredEdge
Jun 25 2015 17:26
!?
it makes sense or doesn't?
your previous explanation was perfect
" I know filter passes each element of an array into a function that checks for a condition and then creates a new array of elements that meet that condition."
adcor
@adcor
Jun 25 2015 17:27
the bit that you posted makes sense, now I need to apply the principle to the problem and see if I fully understand it
EngineeredEdge
@EngineeredEdge
Jun 25 2015 17:27
well, good. I would modify to "Filter passes each element of an array into a function and checks if the function returns true or false. it creates a new array of elements that return true"
Róbert Már Maríuson
@Gigglefeet
Jun 25 2015 17:28
So how does one get help here? Simply by crying help? or does one say hey I’m at Waypoint: Add Borders Around your Elements, and some boxes that should be ticked (according to me) aren’t ticked,
Screen Shot 2015-06-25 at 19.27.38.png
the think is, I have created the thick-green border element but it doesn’t get the green tick?????
adcor
@adcor
Jun 25 2015 17:29
Thanks for all your help @EngineeredEdge
EngineeredEdge
@EngineeredEdge
Jun 25 2015 17:29
@Gigglefeet post ``` (tildes not quotes) around your code and paste it
Róbert Már Maríuson
@Gigglefeet
Jun 25 2015 17:30
ahh ok will give it a try
EngineeredEdge
@EngineeredEdge
Jun 25 2015 17:32
@adcor you are welcome. either way, you should try using nested for loops to solve the problem.
here's a boilerplate
function destroyer(someNum) {
    var res = [],
        tmp;

    for (outer loop) {
        tmp = true;

        for (inner loop) {

            if (condition) {
                tmp = false;
            }
        }

        if (tmp) {
            res.push(something);
        }
    }
    return res;
Róbert Már Maríuson
@Gigglefeet
Jun 25 2015 17:32
@EngineeredEdge this made only the top and bottom red x’s go green but these are still red
Screen Shot 2015-06-25 at 19.32.23.png
EngineeredEdge
@EngineeredEdge
Jun 25 2015 17:33
hmm, i can't see your code
Róbert Már Maríuson
@Gigglefeet
Jun 25 2015 17:33
sorry, will paste it in
@EngineeredEdge
Screen Shot 2015-06-25 at 19.33.40.png
EngineeredEdge
@EngineeredEdge
Jun 25 2015 17:34
and does that produce a thick green border?
Róbert Már Maríuson
@Gigglefeet
Jun 25 2015 17:34
can it have something to do with having two classes in the img element?
No there is no green border I can see
EngineeredEdge
@EngineeredEdge
Jun 25 2015 17:35
so then obviously the html isn't recognizing the second class, correct?
Logan Tegman
@ltegman
Jun 25 2015 17:35
@Gigglefeet Yeah, you need to just use on class parameter and put all classes you want to apply within the quotes, separated by spaces
Bianca Mihai
@biancamihai
Jun 25 2015 17:35
@Gigglefeet class="class1 class2 class3"
EngineeredEdge
@EngineeredEdge
Jun 25 2015 17:35
lol guys just giving answers
the next question should have been "what should you google to find out how to assign multiple classes to an html element"
learning googleFu is important
Francesco
@FrancescoFilippi
Jun 25 2015 17:36
Anyone experiencing issues on Bonfire #125? The Smallest Common Multiple one.
Róbert Már Maríuson
@Gigglefeet
Jun 25 2015 17:37
ok will try it, sorry for the stupid Q: I am a complete newbie just started 3 weeks ago with html and css
and I new this, but did not remember it when push came to shove :)
EngineeredEdge
@EngineeredEdge
Jun 25 2015 17:37
not stupid q
just trying to help you reason through your hurdle
Francesco
@FrancescoFilippi
Jun 25 2015 17:38
Tests console keep telling me that scm[1,5] should be 60
Róbert Már Maríuson
@Gigglefeet
Jun 25 2015 17:38
@biancamihai thanx that worked like a milk bottle on a baby :)
will try google first next, if this sentence makes any sense :)
Ariel
@ArielLeslie
Jun 25 2015 17:38
Another thing we need to keep in mind is that getting useful google results does come from experience picking the right terms to search for and identifying the useful ones.
Eko Julianto Salim
@ekojsalim
Jun 25 2015 17:39
@FrancescoFilippi you need to find the smallest common multiple of the numbers in the range :)
Ariel
@ArielLeslie
Jun 25 2015 17:39
It's one of those things you pick up without noticing, but I've seen how differently I search for code help than newbs do
ronaldrdguez
@ronaldrdguez
Jun 25 2015 17:40
@FrancescoFilippi that is correct isn’t it?
Francesco
@FrancescoFilippi
Jun 25 2015 17:40
@ekojsalim woooooo that's why
:D
EngineeredEdge
@EngineeredEdge
Jun 25 2015 17:42
@arielleslie agreed and this was a good example to use google for. he clearly understood classes, just not how to add multiple classes to an html element
simple google
Róbert Már Maríuson
@Gigglefeet
Jun 25 2015 17:42
plus I have to admit this was my first problem and I panicked :)
Ariel
@ArielLeslie
Jun 25 2015 17:43
I'm not disagreeing, I'm just reminding myself and the other pros that we want to encourage newbs instead of always respoding "GAH! Do you even Google????"
Moisés Man
@moigithub
Jun 25 2015 17:43
http://codepen.io/MMan/full/KpXOxV/ my ugly pomodoro zipline :) just finished
EngineeredEdge
@EngineeredEdge
Jun 25 2015 17:43
very nice
Ariel
@ArielLeslie
Jun 25 2015 17:44
@moigithub Every time I see your username I read it as MOISTihub
ronaldrdguez
@ronaldrdguez
Jun 25 2015 17:46

I have a question. Is there a more or less standard way to indent JS code, I’m looking for a post with some common guidelines or something, specially whith all those nested callbacks. I mean...

return movieLists.map(function(movieList) {
    return movieList.videos.map(function(video) {
      return video.boxarts.filter(function(boxart) {
        return boxart.width === 150;
      }).map(function(boxart) {
        return {id: video.id, title: video.title, boxart: boxart.url};
      });
  }).concatAll();
}).concatAll();

This doesn’t look much readable to me.

EngineeredEdge
@EngineeredEdge
Jun 25 2015 17:47
i think such deep nesting in general makes a function harder to read. but I am not sure you could get much better than that
Ariel
@ArielLeslie
Jun 25 2015 17:49
@ronaldrdguez COMMENTS! :D
For real though people, comment yo' shit
Bianca Mihai
@biancamihai
Jun 25 2015 17:49
@Gigglefeet you are welcomed and yes google it first next time ;)
Róbert Már Maríuson
@Gigglefeet
Jun 25 2015 17:50
Have to say, this forum is Mekka for a big newbie like me :) cheers and thanx for all the fish :)
Lightwaves
@Lightwaves
Jun 25 2015 17:53
@arielleslie what the heck is a moistihub it sounds terrible :laughing:
Ariel
@ArielLeslie
Jun 25 2015 17:53
exactly
Moisés Man
@moigithub
Jun 25 2015 17:55
i should put something like Lie Arielles :sparkles:
Ariel
@ArielLeslie
Jun 25 2015 17:56
Yeah, I recently had it pointed out to me that mine looks like arielles lie. In most places caps are allowed and it's ArielLeslie, which makes much more sense. :)
ronaldrdguez
@ronaldrdguez
Jun 25 2015 17:56
@arielleslie True, I just picked this from the functional programming exercises. However, even if I do put comments there, it may help you understand what it does but it doesn’t improve readability of the code itself. I’m talking more of indentation, sometimes I’ve seen constructs like these when chaining calls for instance...
a() 
.b()
.c() // dots indented
Ariel
@ArielLeslie
Jun 25 2015 17:58
I think that comments and white space improve the readability in a case like that one where you have so much short nesting but the only way I can think of to make the code itself more readable is maybe to alias
ronaldrdguez
@ronaldrdguez
Jun 25 2015 18:06
@arielleslie , @EngineeredEdge Looks like this is just another JS thing I’m gonna have to live with.
Ariel
@ArielLeslie
Jun 25 2015 18:11
To be fair, I doubt that comes up terribly often.
Steven Leiva
@StevenXL
Jun 25 2015 18:12
@EngineeredEdge No I haven't gotten to that problem yet.
I'm on it now but haven't really gotten too deep into it.
conceptually, I think I know how to do it. use the jquery.getJSON method to fetch the data; that method also takes a function of what to do with the data.
Logan Tegman
@ltegman
Jun 25 2015 18:14
@ronaldrdguez I know a lot of people who like the airbnb JS style guide, which has rules for method chaining, but whether or not that makes it more or less readable is really up to the individual. https://github.com/airbnb/javascript#18.5
ronaldrdguez
@ronaldrdguez
Jun 25 2015 18:24
@ltegman thanks I’ll look into it.
Matt Trifilo
@itxchy
Jun 25 2015 19:07

Bonfire - Seek and Destroy

function destroyer(arr) {

    // initiallize args array to store arguments
    var args = [];
    // push arguments to the args array
    for (var i = 1; i < arguments.length; i++) {
        args.push(arguments[i]);
    }
    // test args array
    console.log(args);

    // check for the numbers within arr against arguments, then destroy the matches
   arr.filter(function (number) {
    for (var j = 0; j < args.length; i++) {
        // if the arg doens't match current element, return element
        if (args[j] !== number) {
            // debugging
            console.log("number: " + number);
            console.log("args[j}: " + args[j]);
            return number;
        } else {
            // if the arg does match, destroy
            arr.splice(args[j], 1);
        }
    }
  });
  return arr;
}

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

I'm getting an infinite loop (or just super slow). Any ideas why? It's tough to debug without any errors to go by.

Krzysztof Miąsko
@kmiasko
Jun 25 2015 19:09
splice changes the args in a loop maybe thats why
Rasheed Bustamam
@abustamam
Jun 25 2015 19:10
keep in mind you're using both filter and if/else statements
remember in filters, you simply return a boolean that states whether or not you keep the element
Krzysztof Miąsko
@kmiasko
Jun 25 2015 19:11
and you're incrasing i, and using j
Rasheed Bustamam
@abustamam
Jun 25 2015 19:11
oh, nice catch
Krzysztof Miąsko
@kmiasko
Jun 25 2015 19:11
thats why infinite
Matt Trifilo
@itxchy
Jun 25 2015 19:12
Ahh... of course. Thank you @kmiasko and @abustamam! :smile:
Krzysztof Miąsko
@kmiasko
Jun 25 2015 19:13
np, gl
Briana Swift
@brianamarie
Jun 25 2015 19:37
Quick big-o notation question: does T(n) == O(n), and does O stand for the algorhythm that is in question?
O is 'worst case' for the alg in question
T is the actual number of operations
Rasheed Bustamam
@abustamam
Jun 25 2015 19:48
this is my code for spinal tap case (spoilers)
```
function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins

  var res = '';

  if (str.indexOf(' ') == -1 && str.indexOf('_') == -1){
    for (var i = 0; i < str.length; i++){
      if (str[i] == str[i].toUpperCase()){
        res += "-" + str[i].toLowerCase();
      }
      else {
        res += str[i];
      }
    }
    return res;
  }


  return str.toLowerCase().replace(/\s/g, '-').replace(/\_/g, '-');
}

spinalCase('This Is Spinal Tap');
It doesn't seem very elegant though... any tips on improving? thakns
the camelcase really tripped me up
Briana Swift
@brianamarie
Jun 25 2015 19:53
@abustamam thank you!
Bianca Mihai
@biancamihai
Jun 25 2015 19:59
@abustamam what about if you make the string lowercase, then you split on space and then using the map function you transform every first letter to uppercase and return the array joind by ‘-‘?
Godfrey Chiu
@ggwc82
Jun 25 2015 20:03
hi, can someone please help me understand why I'm not getting the correct output for part of the permutations bonfire? I coded Heap's algorithm from wiki, and with other sources too, manage to get it to output to console.log, correctly. But when I try to push each permutation to my results array, it doesn't quite work correctly.
for the following part of my code: function permutations(n, arr) {
if (n === 1) {
console.log(arr);
results.push(arr);
return;
console.log(arr) returns the correct permutations list [ 'a', 'a', 'b' ]
[ 'a', 'a', 'b' ]
[ 'b', 'a', 'a' ]
[ 'a', 'b', 'a' ]
[ 'a', 'b', 'a' ]
[ 'b', 'a', 'a' ]
but results.push(arr) gives me an array of the following: [ [ 'a', 'a', 'b' ],
[ 'a', 'a', 'b' ],
[ 'a', 'a', 'b' ],
[ 'a', 'a', 'b' ],
[ 'a', 'a', 'b' ],
[ 'a', 'a', 'b' ] ]
in heaps algorithm, thats the only line that logs to the console, so why can't I 'log' or push that same 'arr' to my results array?
Timothy Touch
@timtouch
Jun 25 2015 20:08
Mind if you show your code?
Godfrey Chiu
@ggwc82
Jun 25 2015 20:09
whats that github method for pasting coe?
Timothy Touch
@timtouch
Jun 25 2015 20:09
``` before and after your code
like
```
Godfrey Chiu
@ggwc82
Jun 25 2015 20:10

'''
function permAlone(str) {
var firstperm = str.split("");
var results = [];

permutations(firstperm.length, firstperm);

function permutations(n, arr) {
if (n === 1) {
console.log(arr);
results.push(arr);
return;
}
else {
for (var i = 0; i < n; i++) {
permutations(n-1, arr);
if (n%2 === 0) {
var tmp = arr[i];
arr[i] = arr[n-1];
arr[n-1] = tmp;
}
else {
var tmp1 = arr[0];
arr[0] = arr[n-1];
arr[n-1] = tmp1;
}
}
}
}

return results;
}

permAlone('aab');
'''

Bianca Mihai
@biancamihai
Jun 25 2015 20:10
@abustamam looked now at http://www.freecodecamp.com/challenges/bonfire-spinal-tap-case and what I wrote early is not ok :)
Godfrey Chiu
@ggwc82
Jun 25 2015 20:10
urgh, what happened to my formatting
Timothy Touch
@timtouch
Jun 25 2015 20:11
@ggc100 It's backticks, the key above tab
Godfrey Chiu
@ggwc82
Jun 25 2015 20:11
function permAlone(str) {
  var firstperm = str.split("");
  var results = [];

  permutations(firstperm.length, firstperm);

  function permutations(n, arr) {
    if (n === 1) {
    console.log(arr);
    results.push(arr);
    return;
    }
    else {
      for (var i = 0; i < n; i++) {
        permutations(n-1, arr);
        if (n%2 === 0) {
          var tmp = arr[i];
          arr[i] = arr[n-1];
          arr[n-1] = tmp;
        }
        else {
          var tmp1 = arr[0];
          arr[0] = arr[n-1];
          arr[n-1] = tmp1;
        }
      }
    }
  }

  return results;
}

permAlone('aab');
thanks!
Timothy Touch
@timtouch
Jun 25 2015 20:11
Cool
Godfrey Chiu
@ggwc82
Jun 25 2015 20:11
still new to gitter
Timothy Touch
@timtouch
Jun 25 2015 20:12
You'll get used to it
Godfrey Chiu
@ggwc82
Jun 25 2015 20:16
are we expected to write this code entirely ourselves? I mean, its the first time I've come across recursion in the FCC curriculumn, and whilst I did encounter it before in Python courses, I was a bit surprised when i saw it appearing in a bonfire without a tutorial on it
Logan Tegman
@ltegman
Jun 25 2015 20:17
@ggc100 I definitely feel like quite a few of the Bonfires as they're written right now just leave you up to your own devices to find the right pattern or function for the job. I think I saw someone not solve that with recursion though, so I don't think it requires it.
Ariel
@ArielLeslie
Jun 25 2015 20:18
I had that same feeling, and then I realized that a bug was making my "next" button bounce me all over the map.
Godfrey Chiu
@ggwc82
Jun 25 2015 20:18
@ltegman yea, I was considering manually coding it with johnson trotter, which is actually faster than the recursive algo
Ariel
@ArielLeslie
Jun 25 2015 20:19
Overall though, yeah. I would argue that it just gives you the assignment and leaves you to figure out how to do it
To be fair, I think that builds really necessary googling skills.
Godfrey Chiu
@ggwc82
Jun 25 2015 20:19
and the 'hints' I found, especially the ones saying .reduce might be helpful, actually just wasted my time looking down the wrong paths!
Ariel
@ArielLeslie
Jun 25 2015 20:19
The problem with codecademy is that it baby steps you through but then you don't have any idea what to do with what you've learned or how to use it
Godfrey Chiu
@ggwc82
Jun 25 2015 20:21
any idea on why my lines console.log(arr);
results.push(arr); give different outputs?
console.log(arr) being correct, but results.push(array) just gives me an array with the same permutations, repeated
Timothy Touch
@timtouch
Jun 25 2015 20:26
I know what I did to work around this, but I don't actually know why it does that...
Godfrey Chiu
@ggwc82
Jun 25 2015 20:27
logically it should work right?
Timothy Touch
@timtouch
Jun 25 2015 20:28
You would think so
Ariel
@ArielLeslie
Jun 25 2015 20:29
where is results first defined?
Godfrey Chiu
@ggwc82
Jun 25 2015 20:31
its at the top, in permAlone function but before the main heap algorithm
Ariel
@ArielLeslie
Jun 25 2015 20:33
ah. I see it
mommadona
@mommadona
Jun 25 2015 20:34
THIS is for: HELP ~ This is what I've entered under #9 STYLE challenge <h2 style="color:red"> CatPhotoApp </h2> || And, this is what pops up:
Robert Ozimek
@robertozimek
Jun 25 2015 20:34
@ggc100 the problem is that it’s push the same reference of the arr to the results array in memory, its not copying it.. if you change results.push(arr) to results.push(arr. slice()) it works
mommadona
@mommadona
Jun 25 2015 20:34
Your h2 element should be red. Sorry about that = hit the enter too soon ~
Ariel
@ArielLeslie
Jun 25 2015 20:34
It seems like console.log(arr) only hits for words of length 1, is that correct?
mommadona
@mommadona
Jun 25 2015 20:35
The h2 DOES turn red, so something is working ~ I just won't let me go to #10 step
Godfrey Chiu
@ggwc82
Jun 25 2015 20:36
@robertozimek thanks, that works now! im not exactly following what you're saying though
Ariel
@ArielLeslie
Jun 25 2015 20:38
@mommadona try refreshing the page? that should be right
Godfrey Chiu
@ggwc82
Jun 25 2015 20:38
I dont understand how slice would work vs the non.slice method
Robert Ozimek
@robertozimek
Jun 25 2015 20:39
@ggc100 since an array is an object, its passed by reference so it just points to the place in memory, so each time you changed arr it changed the arr memory location and your results had only multiple copies of the reference to that same exact memory location
while slice makes a whole new memory location
Godfrey Chiu
@ggwc82
Jun 25 2015 20:42
@robertozimek I think I need to look into this concept more. I guess I need to go back to those udacity oop courses!
@robertozimek do you know of any decent resources that explains this concept?
Justin Ceballos
@reliable-justin
Jun 25 2015 20:43
Why does CSS use the href attribute <link href=“style.css” rel=“stylesheet” type=“text/css”>, while jQuery uses the src attribute <script type=“text/javascript” src=“script.js”></script>?
Robert Ozimek
@robertozimek
Jun 25 2015 20:44
@ggc100 yeah or google the difference between passing variables by reference and by value
I’m sure there is a diagram out there that shows and explains it better than I can
Timothy Touch
@timtouch
Jun 25 2015 20:45
So when you use console.log(arr) you are looking at the arr at that point in time but when you push the arr, you are pushing the actual reference?
mommadona
@mommadona
Jun 25 2015 20:46
@arielleslie I'll try that ~ TY!
Godfrey Chiu
@ggwc82
Jun 25 2015 20:46
just saw the stackexchange explaination
Robert Ozimek
@robertozimek
Jun 25 2015 20:47
yeah the console.log(arr) is happening as the function runs so the memory hasn’t changed yet, while by the time you look inside the results array the values have changed already
because they were only references to the place in memory
mommadona
@mommadona
Jun 25 2015 20:47
I'll need to wait til server comes back on ~
Robert Ozimek
@robertozimek
Jun 25 2015 20:47
rather than separate copies
Ariel
@ArielLeslie
Jun 25 2015 20:48
I suspect it's just a connection issue @mommadona
Godfrey Chiu
@ggwc82
Jun 25 2015 20:49
I must admit, I'm still trying to fully absorb the concept! but thanks for the assist, I need to study more!
Robert Ozimek
@robertozimek
Jun 25 2015 20:55
@ggc100 yeah maybe I’m not that good at explaining the concept but maybe after some time you will begin to understand it, once you come across it again
Godfrey Chiu
@ggwc82
Jun 25 2015 20:57
@robertozimek its probably my slow brain :) but its great that people like you are always willing to help, I think thats the great thing about FCC
Robert Ozimek
@robertozimek
Jun 25 2015 20:58
yeah I guess we all had to start somewhere and it took me some time to grasp some concepts along the way as well
jgadjiev
@jgadjiev
Jun 25 2015 21:08
the oop stuff is definately really hard to understand at first
I recently started learning it and it is really confusing and all over the place for me
Daniel Simão
@simaodeveloper
Jun 25 2015 21:21
Hey folks, anybody can help me, this exercise is working? http://www.freecodecamp.com/challenges/bonfire-smallest-common-multiple
Godfrey Chiu
@ggwc82
Jun 25 2015 21:22
@jgadjiev totally agree with you. I found that I had perhaps understood maybe 25% of the oop udacity lessons. The functional programming tutorial with 42 steps was probably the worst of the FCC curriculum imo. Must mention this to Quincy
Daniel Simão
@simaodeveloper
Jun 25 2015 21:27
@CodeNonprofit the tests this question is wrong,I believe it is easy to fix this...no? http://www.freecodecamp.com/challenges/bonfire-smallest-common-multiple
Gabriel Nunes
@Hezag
Jun 25 2015 21:31
The second test is always failing to me.
Luke Pensiero
@VonCrab
Jun 25 2015 21:32
@Hezag From what I understand it's currently broken
At least the last I heard
Gabriel Nunes
@Hezag
Jun 25 2015 21:32
Ok, @VonCrab, thanks!
Logan Tegman
@ltegman
Jun 25 2015 21:32
@simaodeveloper The tests for this are correct.
@VonCrab is right that the HTML entity bonfire is currently broken
Luke Pensiero
@VonCrab
Jun 25 2015 21:33
So I have a question: what happens when your tests work but the FCC webpages locks-up when I submit the solution
Daniel Simão
@simaodeveloper
Jun 25 2015 21:33
@Hezag no, It does not work too! skip it.
Luke Pensiero
@VonCrab
Jun 25 2015 21:33
Should I try all of the test cases that FCC is doing?
Ariel
@ArielLeslie
Jun 25 2015 21:34
... are you creating an infinite loop?
Daniel Simão
@simaodeveloper
Jun 25 2015 21:34
@Itegman How smallest common multiple of 1 and 5 is 60?
Luke Pensiero
@VonCrab
Jun 25 2015 21:35
@arielleslie I'm manually testing now, on my end no infinite loops
I'm going to keep checking
Logan Tegman
@ltegman
Jun 25 2015 21:35
@simaodeveloper You need to find the smallest common multiple of every number within the range of 1 - 5
Ariel
@ArielLeslie
Jun 25 2015 21:35
you might be having a connection issue with the FCC website. That seems to be happening to some people
Luke Pensiero
@VonCrab
Jun 25 2015 21:38
@arielleslie I think I found it, one of the test cases was causing an infinite loop
Daniel Simão
@simaodeveloper
Jun 25 2015 21:38
@ltegman ahhhh I understand now . Thanks !!!
Logan Tegman
@ltegman
Jun 25 2015 21:38
@simaodeveloper no problem :smile:
Luke Pensiero
@VonCrab
Jun 25 2015 21:54
ahh so apparently the fact that the numbers I'm using are non-exact is causing an issue during calculations
i.e. 94.46 !== 94.460000000001;
Ariel
@ArielLeslie
Jun 25 2015 21:56
@VonCrab yeah. That's always fun.
Robert Ozimek
@robertozimek
Jun 25 2015 22:01
@VonCrab try using Math.round() or look into Math.floor() or Math.ceil()
Luke Pensiero
@VonCrab
Jun 25 2015 22:06
@robertozimek I'm doing the exact change bonfire, so the rounding methods wouldn't work and the percision method returns a string
the problem is occurring when I add 1 penny, i.e. 0.01 to my sum accumulator (which breaks the while loop)
I'm considering convering everything to cents
Robert Ozimek
@robertozimek
Jun 25 2015 22:08
ahh I see
Luke Pensiero
@VonCrab
Jun 25 2015 22:09
yeah its that one penny which causes the whole thing to loop forever, which means it could happen with any denomination so its a good time to rethink how I handle the values
rtrom
@rtrom
Jun 25 2015 22:12
Anyone have a second to review my code? Working through the Bonfire with Palindromes, and I'm pretty sure I have a syntax error somewhere.
function palindrome(str) {
    string.toLowerCase().replace(/ /g, '');
    if (str == string.split('').reverse.().join('')) {
        return true;
    } else {
        return false;
    }
}

palindrome("eye");
Kristin Anthony
@anthkris
Jun 25 2015 22:17
@rtrom One thing I see is that string .toLowerCase should be str.toLowerCase()
Daniel Simão
@simaodeveloper
Jun 25 2015 22:18
yep
Robert Ozimek
@robertozimek
Jun 25 2015 22:18
@rtrom missing an = it should be three === and your reverse.() should be reverse()
Daniel Simão
@simaodeveloper
Jun 25 2015 22:18
in replace using /\s/g
Kristin Anthony
@anthkris
Jun 25 2015 22:18
@rtrom You might also consider abstracting (in this case, creating a variable to hold your test condition) and make your code easier to read
Daniel Simão
@simaodeveloper
Jun 25 2015 22:19
string.split('').reverse.().join('') to str.split('').reverse.().join('')
Robert Ozimek
@robertozimek
Jun 25 2015 22:19
@rtrom also inside the if statement the string.split should also be str.split
Daniel Simão
@simaodeveloper
Jun 25 2015 22:20
yep
Kristin Anthony
@anthkris
Jun 25 2015 22:21
Thought I'd post my code for the map the debris challenge to se if anyone has any suggestions to make it better:
This message was deleted
rtrom
@rtrom
Jun 25 2015 22:22
Thanks everyone. First instinct was to abstract, but I've had issues in the past with code not passing if I deviate too far from the structure.
Kristin Anthony
@anthkris
Jun 25 2015 22:23
function orbitalPeriod(arr) {
  var GM = 398600.4418;
  var earthRadius = 6367.4447;
  var radius;
  var velocity = 0;
  var period = 0;
  //calculate orbital period

  for (var i = 0; i < arr.length; i++){
    radius = earthRadius + arr[i].avgAlt;
    //v = sqrt(GM/earthRadius*avgAlt)
    velocity = Math.sqrt(GM / radius);
    //P = 2pi * ((earthRadius + avgAlt) / v)
    period = Math.round(2 * Math.PI * (radius / velocity));
    //update avgAlt value and key name
    arr[i].avgAlt = period;
    arr[i].orbitalPeriod = arr[i].avgAlt;
    delete arr[i].avgAlt;
  }

  return arr;
Jonathan
@jonathantimm
Jun 25 2015 22:23
Anybody see something wrong with this code? I thought I have it exactly like the example but it's not working...
image = new SimpleImage("fence-ivy.jpg");

for (pixel: image) {
  avg = (pixel.getRed() + pixel.getGreen() + pixel.getBlue())/3;

  if {(pixel.getGreen() > avg) {
  pixel.setGreen(0);
  }
}

print(image);
This is from the Cs101 class, week 3.
rtrom
@rtrom
Jun 25 2015 22:25
Missing a bracket, maybe?
I count three opening brackets, but only two closing.
Luke Pensiero
@VonCrab
Jun 25 2015 22:27
@arielleslie got it working, thanks for the link!
Ariel
@ArielLeslie
Jun 25 2015 22:28
Yay :sparkles:
Kristin Anthony
@anthkris
Jun 25 2015 22:28
@jonathantimm Yep you have a stray open bracket after the start of the if statement
Luke Pensiero
@VonCrab
Jun 25 2015 22:28
Though toFixed returns a string... so I had to coerce my accumulator which doesn't feel right
Jonathan
@jonathantimm
Jun 25 2015 22:29
@rtrom @anthkris thanks guys!
Ariel
@ArielLeslie
Jun 25 2015 22:30
@VonCrab cast it back to a number?
Eric Tillberg
@Thrillberg
Jun 25 2015 22:30
can anyone help me with the missing letters bonfire?
Ariel
@ArielLeslie
Jun 25 2015 22:30
there might be a math function for floating point precision as well
Luke Pensiero
@VonCrab
Jun 25 2015 22:32
seems most of the math functions involve rounding to integers
rtrom
@rtrom
Jun 25 2015 22:36
So, updated with the suggestions. But, the code won't validate when it checks for palindromes beyond "eye".
```
Robert Ozimek
@robertozimek
Jun 25 2015 22:36
@anthkris arr[i].avgAlt = period; is unnecessary, could just set arr[i].orbitalPeriod = period;
rtrom
@rtrom
Jun 25 2015 22:36
function palindrome(str) {
    str.toLowerCase().replace(/\s/g, '');
    if (str === str.split('').reverse().join('')) {
        return true;
    } else {
        return false;
    }
}

palindrome("eye");
Timothy Touch
@timtouch
Jun 25 2015 22:38
str = str.toLowerCase().replace(/\s/g, '');
toLowerCase() does not change string
Logan Tegman
@ltegman
Jun 25 2015 22:40
@rtrom You may also run into some issues with test case 5 because it contains punctuation, which the \s regex operator will not find and remove.
rtrom
@rtrom
Jun 25 2015 22:42
@ltegman Ah ok. I am absolutely awful with regex. And @timtouch thanks for that; I just reviewed the docs, and see exactly what you mean.
Logan Tegman
@ltegman
Jun 25 2015 22:44
@rtrom Yeah, regex definitely takes time. I've been programming off and on for a couple years and that's still a sticking point for me. I highly recommend playing around with https://regex101.com/ . It's a great place because it lets you test regex in real time and also has a reference that contains a bunch of the symbols.
Eric Tillberg
@Thrillberg
Jun 25 2015 22:46
if anyone has a minute i'd really appreciate some help with the missing letters bonfire :)
rtrom
@rtrom
Jun 25 2015 22:46
@ltegman Thanks for that! Bookmarked. I will have to play with it some more. For this bonfire, I think I have to figure out how to not just convert the string, but store the value to some variable, and get my regex operators in line. Struggling a bit; felt like I fell off into the deep end once I got to the bonfires.
Logan Tegman
@ltegman
Jun 25 2015 22:48
@Thrillberg I'll do my best, what's up?
Eric Tillberg
@Thrillberg
Jun 25 2015 22:48
@ltegman thanks! well, i'm having trouble just conceptualizing my approach to the problem
@ltegman ive just been playing around with some options but i dont see a realistic way forward
Logan Tegman
@ltegman
Jun 25 2015 22:49
@Thrillberg What kinds of ideas have you had so far? Wondering if what you've got just needs some tweaking or not.
Eric Tillberg
@Thrillberg
Jun 25 2015 22:49
@ltegman well here's my code so far

```function fearNotLetter(str) {

var alphabet = "abcdefghijklmnopqrstuvwxyz".split('');
console.log(alphabet);

for (i = 0; i < str.length; i ++) {
console.log(String.fromCharCode(str.charCodeAt(i)));
str[i].indexOf(alphabet);
}

return str;
}

fearNotLetter('abce');
```

shoot, how do i make it look like code?
Lightwaves
@Lightwaves
Jun 25 2015 22:50
put it between the backticks
Logan Tegman
@ltegman
Jun 25 2015 22:50
Gotta put a line break in between the first set of ``` and the first line of code
``` has to have its own line
Eric Tillberg
@Thrillberg
Jun 25 2015 22:50
function fearNotLetter(str) {

  var alphabet = "abcdefghijklmnopqrstuvwxyz".split('');
  console.log(alphabet);

  for (i = 0; i < str.length; i ++) {
    console.log(String.fromCharCode(str.charCodeAt(i)));
    str[i].indexOf(alphabet);
  }



  return str;
}

fearNotLetter('abce');
ah ok got it
Moisés Man
@moigithub
Jun 25 2015 22:51
indexOf will search if exist or not... NO matter if is ordered or not...
so ur alphabet can be .... "rtweqdapuiueortbmn" <-- unordered chars.. and it still be saying "char found"
that do not guarantee its consecutive
Eric Tillberg
@Thrillberg
Jun 25 2015 22:52
im not sure i understand @moigithub
Logan Tegman
@ltegman
Jun 25 2015 22:54
@Thrillberg You're going to need some way in your code of comparing each character of the input string to what you expect it to be. You can determine what you expect a given character of the string to be by using the previous character since you're looking for a sequence.
Eric Tillberg
@Thrillberg
Jun 25 2015 22:54
hmmm that helps
i need to think on this a bit more
thanks @ltegman !
Logan Tegman
@ltegman
Jun 25 2015 22:55
@Thrillberg Good luck! I'm sure you'll get there eventually :smile:
Moisés Man
@moigithub
Jun 25 2015 22:56
that exercise want u to say wich letter is missing :).... so u have
a,b,c.. what follow next ??
i think u know its.. "d" and then "e".. but how u tell the computer to find out.. and return "d"
Robert Ozimek
@robertozimek
Jun 25 2015 22:59
@Thrillberg also a hint: char codes(or ASCII) are pretty close to each other so A is 65 and B would be 66, as long as they are the same case because lower case a is 97 and b is 98. Just keep that in mind. You can refer to this table if it helps http://www.asciitable.com/
Justin Walters
@FFX01
Jun 25 2015 23:01

'''function convert(str) {
var checkFor=/[\u00A0-\u9999<>\&]/g;
var encodedStr=str.replace(checkFor,function(i){
return '&'+HtmlReplace[i.charCodeAt(0)]+";";
});
return encodedStr;
}

var HtmlReplace={
38: "amp",
60: "lt",
62: "gt",
34: "quot",
39: "apos"
};

convert('<>');'''

keeps giving me: should escape characters: expected '<>' to equal '<>'
Robert Ozimek
@robertozimek
Jun 25 2015 23:02
that one is broken
it should be convert(‘<>’) in the test case but it has a bug
Justin Walters
@FFX01
Jun 25 2015 23:02
works not sure why. console returns correct html entity
oh ok
Robert Ozimek
@robertozimek
Jun 25 2015 23:03
yeah your code is good, just a bug with the bonfire
Justin Walters
@FFX01
Jun 25 2015 23:03
any workaround for the bug?
Robert Ozimek
@robertozimek
Jun 25 2015 23:03
yeah I guess you can use the Dev Console to change the source code
Justin Walters
@FFX01
Jun 25 2015 23:04
I'll give that a shot.
Justin Walters
@FFX01
Jun 25 2015 23:07
thank you.
Alfonso Balsera Martinez
@AlfonB6
Jun 25 2015 23:14
guys i need quick help
Robert Ozimek
@robertozimek
Jun 25 2015 23:14
@FFX01 if you need any help let me know, I figured out where to hack it to make it pass, but maybe a fun exercise to read someone elses code and hack it to work.
Alfonso Balsera Martinez
@AlfonB6
Jun 25 2015 23:16

if i would like to find the largest number of 3 created random numbers between 1 and 100??
this is what i use for random:

Math.floor(Math.random()*100);

i know i can use Math.max on values but i cant on arrays :( or at least i odnt know how

Lightwaves
@Lightwaves
Jun 25 2015 23:17
Math.max.apply(null, array)
Justin Walters
@FFX01
Jun 25 2015 23:21
@robertozimek i will see if i can do it first, but if i cant ill let you know
Alfonso Balsera Martinez
@AlfonB6
Jun 25 2015 23:25
how can i push the values i get from a for in loop to an array?
var myarry = [];
for (var i=1; i === 3; i++) {
myarray.push(i);
}
Moisés Man
@moigithub
Jun 25 2015 23:26
ur condition is not correct.. i=1.... 1 ===3 will return false and finish the loop
Robert Ozimek
@robertozimek
Jun 25 2015 23:26
@AlfonB6 your for loop doesn’t run, the test case i === 3 isn’t true from the start of the loop
Moisés Man
@moigithub
Jun 25 2015 23:28
var myarray = [];
for (var i=1; i< 3; i++) {
myarray.push(i);
}
console.log(myarray); // <-- will give u [1,2]
Alfonso Balsera Martinez
@AlfonB6
Jun 25 2015 23:29
thank you! got it
Thank you guys!! i finished the randomizer and choose max for 3 numbers
var maximum = [];
for (i=0; i < 3; i++) {
    maximum.push(Math.floor(Math.random()*100));
}    

Math.max.apply(null, maximum)
Alfonso Balsera Martinez
@AlfonB6
Jun 25 2015 23:36
and here is for even numbers!
var maximum = [];
for (i=0; i < 3; i++) {
    maximum.push(Math.floor(Math.random()*100));
    if (maximum[i] % 2 === 0) {
        print(maximum[i]) 
    }
}
not print sorry but console.log
Alfonso Balsera Martinez
@AlfonB6
Jun 25 2015 23:43
in function format so its easier to get the result
var myrandom = function () {
    var maximum = [];
    for (i=0; i < 3; i++) {
        maximum.push(Math.floor(Math.random()*100));
        if (maximum[i] % 2 === 0) {
            console.log('These are the even numbers: ' + maximum[i]);
        }
    } console.log ('The 3 numbers are: ' + maximum);
}
myrandom();
rtrom
@rtrom
Jun 25 2015 23:59
Still struggling with the bonfire to create a palindrome. Here's my code so far. Getting an error on the regex portion specifically, and then syntax errors for the rest. Out of ideas:
function palindrome(str) {
  var word = str.toLowerCase().replace([^\w\s], '');
        if (word === word.split('').reverse.().join('')) {
    return true;
  } else {
    return false;
  }
}

palindrome("eye");