These are chat archives for FreeCodeCamp/Help

8th
Sep 2015
Tim P
@xTimpi
Sep 08 2015 00:04
@olopezg whats your problem?
NickLanza
@ntl88
Sep 08 2015 00:17

I'm stuck on "Use Bracket Notation to Find the First Character in a String" I just don't know understand any of it. It asks to "The first letter of firstLetterOfLastName should be a L." The Code is below. I just don't know what to do.

var firstLetterOfFirstName = "";
var firstLetterOfLastName = "";

var firstName = "Ada";

firstLetterOfFirstName = firstName[0];

var lastName = "Lovelace";

firstLetterOfLastName = lastName;

// Only change code above this line.
// We use this function to show you the value of your variable in your output box.
// You'll learn about functions soon.
(function(v){return v;})(firstLetterOfLastName);

nvm. figured it out
:)
Vince
@VinceDavies
Sep 08 2015 00:37
Use the .pop() function to remove the last item from myArray.
var myArray = ["John", 23, ["cat", 2]];
I'm stuck on this problem.
This is what I wrote: myArray.pop();
What am I doing wrong here? seems very simple
Philip Warkentien II
@warkentien2
Sep 08 2015 00:39
each item of array is separated by a comma.
so: [" john", 23, .... ];
pop() will return [" cat",2] as last item
but if I remember, they want you to return only. 2
@VinceDavies
Vince
@VinceDavies
Sep 08 2015 00:44
@warkentien2 Ah I see... so I need to break the element up?
Philip Warkentien II
@warkentien2
Sep 08 2015 00:46
@VinceDavies exactly. so [[2],[3,[4,5]],6] => [2,3,4,5,6], if it were Ruby, all you'd need to do would be array.flatten
keith2237
@keith2237
Sep 08 2015 00:54
Any idea why every time I go back to a previously completed lesson all my code is gone.
Philip Warkentien II
@warkentien2
Sep 08 2015 01:02
@keith2237 if you click your image in FCC your previous codes are saved there
Vince
@VinceDavies
Sep 08 2015 01:03
@warkentien2 Oh actually I needed to just complete the line they had already provided instead of myArray.pop(); I needed to complete removed.pop()
I figured it out, thanks
CamperBot
@camperbot
Sep 08 2015 01:03
if you want to thank someone, put an @ before their name!
Philip Warkentien II
@warkentien2
Sep 08 2015 01:13
@VinceDavies no problem
Oscar Lopez Guzman
@olopezg
Sep 08 2015 01:13
@tcollier2 Thanks!
CamperBot
@camperbot
Sep 08 2015 01:13
olopezg sends brownie points to @tcollier2 :sparkles: :thumbsup: :sparkles:
:star: 214 | @tcollier2 | http://www.freecodecamp.com/tcollier2
Brian Ball
@ideabrian
Sep 08 2015 01:16
hello all
Raj Vansia
@rajvansia
Sep 08 2015 01:24
@Wastinik i think you need to have statment that removes the mathced numbers from the array
DJColeslaw31
@DJColeslaw31
Sep 08 2015 01:28
I have already mad the image 100 pixels wide but I don't know how to make the image element have the class small-image. Any thoughts?
Nevermind, I figured it out
Matthew Iles
@miles613
Sep 08 2015 01:37
good evening, i'm on the reverse a string bonfire, does anyone have any tips
Aniruddh Agarwal
@anrddh
Sep 08 2015 01:41
Split the string into an array.
Matthew Iles
@miles613
Sep 08 2015 01:43
thanks @awesomeaniruddh
CamperBot
@camperbot
Sep 08 2015 01:43
miles613 sends brownie points to @awesomeaniruddh :sparkles: :thumbsup: :sparkles:
:star: 368 | @awesomeaniruddh | http://www.freecodecamp.com/awesomeaniruddh
Jami Schwarzwalder
@jschwarzwalder
Sep 08 2015 01:44
I am so very stuck on http://freecodecamp.com/challenges/bonfire-where-art-thou can anyone help me
I passed two tests and need to pass the 3rd and 4th
Austin Lin
@austinylin
Sep 08 2015 01:47
@Eiseldora can you paste in what you have so far
Rafael J. Rodriguez
@Rafase282
Sep 08 2015 01:48
bf thou
CamperBot
@camperbot
Sep 08 2015 01:48

:fire:Bonfire: Where art thou :link:

function where(collection, source) {
  var arr = [];
  // What's in a name?
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });

Make a function that looks through a list (first argument) and returns an array of all objects that have equivalent property values (second argument).

more info:  bf details | bf links | hint

Rafael J. Rodriguez
@Rafase282
Sep 08 2015 01:48
hint
CamperBot
@camperbot
Sep 08 2015 01:48
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Rafael J. Rodriguez
@Rafase282
Sep 08 2015 01:48
@Eiseldora you can find hints ont hat room. but It is nice to give it a try here first.
Jami Schwarzwalder
@jschwarzwalder
Sep 08 2015 01:49
function where(collection, source) {
  var arr = [];
  // What's in a name?

  var source_keys = Object.keys(source)
  //console.log(source_keys)
  for(var i = 0; i < collection.length; i++) { // this should be good to go
    //look at every object in the collection array
   var match = [];
        for (var j = 0; j < source_keys.length; j++){
    // if the collection has the key that is in source and the value is the same add it to an array
       // console.log(collection[i].hasOwnProperty(source_keys[j]));
       // console.log(source[source_keys[j]]);
       // console.log(collection[i][source_keys[j]])
          if (collection[i].hasOwnProperty(source_keys[j]) && collection[i][source_keys[j]] == source[source_keys[j]])             {
             arr.push(collection[i]);
            } else {
               arr.pop(collection[i]);
            }


        }


  }

  // console.log(arr);
  return arr;
}
This message was deleted
I also tried
function where(collection, source) {
  var arr = [];
  // What's in a name?

  var source_keys = Object.keys(source)
  //console.log(source_keys)
  for(var i = 0; i < collection.length; i++) { // this should be good to go
    //look at every object in the collection array
   var match = false;
        for (var j = 0; j < source_keys.length; j++){
    // if the collection has the key that is in source and the value is the same add it to an array
       // console.log(collection[i].hasOwnProperty(source_keys[j]));
       // console.log(source[source_keys[j]]);
       // console.log(collection[i][source_keys[j]])
          if (collection[i].hasOwnProperty(source_keys[j]) && collection[i][source_keys[j]] == source[source_keys[j]])             {
              match = true;
            }

        }
        if (match) {
            arr.push(collection[i]);

        //console.log (" ");
      }
  }

  // console.log(arr);
  return arr;
}
`
Austin Lin
@austinylin
Sep 08 2015 01:54
@Eiseldora taking a look now…
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 01:54
what would be a better way to write the callback for arr.filter. That's a lot of Pipes!
function bouncer(arr) {
  var bounce = [false,null,0,undefined,NaN,''];


  function fltr(val, index, array){
      if(val == false || val == null || val == 0 || val == undefined || val == NaN || val == ''){
          return false;
      }else{
          return true;
      };
  };
  var result = arr.filter(fltr);
  return result;
}
Brian Ball
@ideabrian
Sep 08 2015 01:56
@JoelMSwensen - what makes you think that's a lot of pipes?
Maybe you could put them in an array - and check to see if the item is 'in' the array?
Austin Lin
@austinylin
Sep 08 2015 01:56
@Eiseldora based on the output I am seeing it looks like you are adding the correct results twice. For test case 3 you should only have two objects in the result, but you have 4. If you look at the output you’ll see you have the two correct objects, but they appear twice.
Brian Ball
@ideabrian
Sep 08 2015 01:56
@JoelMSwensen (you have them in the array bounce
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 01:57
I dunno, just kinda seems like there should be a better way to check if something is falsey
Austin Lin
@austinylin
Sep 08 2015 01:57
bf boucer
CamperBot
@camperbot
Sep 08 2015 01:57
Sorry, can't find a bonfire called boucer. [ Check the map? ]
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 01:58
@ideabrian thatnks, that line was superfluous
now it's gone! haha
Brian Ball
@ideabrian
Sep 08 2015 01:58
@JoelMSwensen - premature optimization is a great way to get stuck!
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 01:59
@ideabrian how do you mean that?
like, don't worry about optimization at this point in the game?
Brian Ball
@ideabrian
Sep 08 2015 01:59
@JoelMSwensen - I mean, did you get it working?
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 01:59
yeah, I did :)
Brian Ball
@ideabrian
Sep 08 2015 02:00
it's like.. well, the burger is medium rare.. like you requested.. but I wonder if I cooked it at 350 degrees instead of 375 - if I'd get a different result?
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 02:00
Yeah, i get what you're saying.
Brian Ball
@ideabrian
Sep 08 2015 02:00
@Eiseldora - I've been on that same bonfire today
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 02:01
it just seems a lot of my code ... well I forget why it works two seconds after it finally worked
Brian Ball
@ideabrian
Sep 08 2015 02:01
in that case, it's probably not a bad idea to do another version - see if you can gain some intuition
oOPa
@oOPa
Sep 08 2015 02:02
hi guys
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 02:02
@oOPa hi
Austin Lin
@austinylin
Sep 08 2015 02:02
@JoelMSwensen There is a more compact way to do it, but it’s pretty close to what you are doing:
arr = arr.filter(e => e != false && e != null);
oOPa
@oOPa
Sep 08 2015 02:02
anyone done the fibonacci one
i have no idea why my code isn't working for one particular case
Austin Lin
@austinylin
Sep 08 2015 02:03
@JoelMSwensen or if you don’t want to use arrow notation:
  arr = arr.filter(function (e) {return e != false && e != null});
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 02:03
@ideabrian I do. as best I can anyway. But I like to throw my code in here 'cause it seems like a good idea to see how else to go about it
Austin Lin
@austinylin
Sep 08 2015 02:03
@oOPa paste in what you have so far.
Brian Ball
@ideabrian
Sep 08 2015 02:03
@JoelMSwensen - the thing about the || operator , is that as soon as it hits a false item, it'll short circuit and return false. So, it's not necessarily a non-optimal way to write something.
oOPa
@oOPa
Sep 08 2015 02:03
'''
CamperBot
@camperbot
Sep 08 2015 02:03
:bulb: to format code use backticks! ``` more info
oOPa
@oOPa
Sep 08 2015 02:04
function sumFibs(num) {
  return fib(num);
}
function fib(n)
{
  if(n == 1) return 1;
  if(n == 2) return 2;

  sum = 2;
  n1 = 1;
  n2 = 1;
  n3 = 0;
  for(i = 0;sum <= n;i++)
    {
      n3 = n1 + n2;
      if(n3 % 2 != 0)
        {
      sum += n3;
        }
      //
      n1 = n2
      n2 = n3;
    }
  return sum;
}
sumFibs(4);
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 02:04
Yeah, and it seemed like the best thing for the job os that bf
oOPa
@oOPa
Sep 08 2015 02:05
@austinylin
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 02:07
@ideabrian Like that! You just reduced my last two hours into 1 line
Brian Ball
@ideabrian
Sep 08 2015 02:07
@JoelMSwensen I did?
Vince
@Vince33
Sep 08 2015 02:09
hey was curious about something and thought maybe I could find a quick answer here'
Screen Shot 2015-09-07 at 10.07.38 PM.png
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 02:09
well, close too ;)
function bouncer(arr) {
arr = arr.filter(function (e) {return e != false && e != null});

    return arr;
};
@ideabrian ^^
Vince
@Vince33
Sep 08 2015 02:10
was wondering why a nav element given the height of 100% would not take the height of its containingdiv
I am using flex box and the nav element is a flex container
Brian Ball
@ideabrian
Sep 08 2015 02:12
@JoelMSwensen - that was @austinylin ;-)
Robert Richey
@0x0936
Sep 08 2015 02:12
@JoelMSwensen return arr.filter(function(e) { if (e) return e; });
Brian Ball
@ideabrian
Sep 08 2015 02:13
@Vince33 - try setting a negative margin (just something I saw the other day)
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 02:13
@austinylin oh god, sorry, thank you :)
CamperBot
@camperbot
Sep 08 2015 02:13
joelmswensen sends brownie points to @austinylin :sparkles: :thumbsup: :sparkles:
:star: 54 | @austinylin | http://www.freecodecamp.com/austinylin
Austin Lin
@austinylin
Sep 08 2015 02:13
@Vince33 Also make sure you dont have any padding. Chrome developer tools is really helpful for this.
@JoelMSwensen no worries :)
@oOPa I’m still looking at your code, it’s a confusing bf.
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 02:16
@0x0936 I don't get how that one is working
Robert Richey
@0x0936
Sep 08 2015 02:19
@JoelMSwensen probably more idiomatic to return true instead of e, but when e is truthy the result is the same
return arr.filter(function(e) { if (e) return true; });
I was mainly just pointing out that you could return the statement instead of first assigning to arr then returning arr
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 02:21
yeah totally
but now I'm intrigued
Vince
@Vince33
Sep 08 2015 02:21
@ideabrian so what is the adavantage of negative margin ? I can bring it down with reg margin but trying not to do that I was trying to take advantage of flexbox and not make thing s to brittle or hardcode to many values
Austin Lin
@austinylin
Sep 08 2015 02:21
@0x0936 good catch! Here is the smallest I think you can make it:
return arr.filter( e => e);
`
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 02:21
how can it tell that when the val is falsey or not without telling it so?
Rex Schrader
@SaintPeter
Sep 08 2015 02:21
You can just return e and it works.
Falsey bouncer, right?
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 02:21
yeah
Rex Schrader
@SaintPeter
Sep 08 2015 02:22
Yup, your filter function can just be return e; and it works :D
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 02:22
because e is tturthy?
Austin Lin
@austinylin
Sep 08 2015 02:22
@JoelMSwensen Array.filter expects a boolean value, so it will automatically convert what it gets back to a boolean. Basically it does all of the work of detecting whether it’s false or true.
Rex Schrader
@SaintPeter
Sep 08 2015 02:23
Which seems a bit counter intuitive, except that filter has an if statement inside its guts which is evaluating e as true/truthy or false/fasley
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 02:23
ok, I think I get it
Rex Schrader
@SaintPeter
Sep 08 2015 02:23
Yeah, what @austinylin said ;)
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 02:23
by the way, is there a reason we are using e?
Robert Richey
@0x0936
Sep 08 2015 02:23
nice, I learned something. thanks @SaintPeter
CamperBot
@camperbot
Sep 08 2015 02:23
0x0936 sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 534 | @saintpeter | http://www.freecodecamp.com/saintpeter
Rex Schrader
@SaintPeter
Sep 08 2015 02:24
@JoelMSwensen Naw, you can use whatever you want. It's just the local parameter name. I usually use item.
Robert Richey
@0x0936
Sep 08 2015 02:25
@JoelMSwensen I usually use el for element
Austin Lin
@austinylin
Sep 08 2015 02:25
@oOPa It looks like your code is including one extra fib number for the final test case. It shouldn’t accept 75025 but it is. That is giving you an output of 135721, instead of 60696.
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 02:25
cool cool, just wondering if there was a convention I should be following there
Rex Schrader
@SaintPeter
Sep 08 2015 02:26
@JoelMSwensen I'd actually encourage you to use a descriptive name, if you're able.
Robert Richey
@0x0936
Sep 08 2015 02:27
@JoelMSwensen my line of thinking is that if the function is a black box - not exposed as an API to other developers, then it's not a sin to abbreviate or abstract the function parameters
Austin Lin
@austinylin
Sep 08 2015 02:28
@oOPa I think you need to move n3 = n1 + n2; to the bottom of the loop and add a condition to the loop to make sure that n3 <= n. Also one suggestion, change the loop from a for loop to a while loop: while(sum <= n && n3 <= n)
@0x0936 Its a black box to the code that is leveraging it, but when you come back to the function years from now you will want comments and clear variable names.
Rex Schrader
@SaintPeter
Sep 08 2015 02:29
@austinylin @oOPa I had a luck doing a do..while loop. The boundry condition is tricky, since you need to check your "highest" fib number prior to adding it to your output or continuing.
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 02:30
@SaintPeter @0x0936 thank you :)
CamperBot
@camperbot
Sep 08 2015 02:30
joelmswensen sends brownie points to @saintpeter and @0x0936 :sparkles: :thumbsup: :sparkles:
:star: 535 | @saintpeter | http://www.freecodecamp.com/saintpeter
:star: 117 | @0x0936 | http://www.freecodecamp.com/0x0936
Robert Richey
@0x0936
Sep 08 2015 02:30
@austinylin I'll argue that if you've been programming for a couple years, then it's a non-issue to understand function(a, b) { /* stuff with a and b */ }
A lot of documentation uses function(a, b) as their examples. So, it's natural to embrace the abstraction.
Austin Lin
@austinylin
Sep 08 2015 02:33
@0x0936 True, but it adds cognitive overhead and when it’s 2 am and the app is down you want all the help you can get :). Only takes a few minutes now but it can save you later. You also want your code to be as readable as possible in general.
Vince
@Vince33
Sep 08 2015 02:34
not to get in the middle of this but clear var names especially in call backs make for happy team members
if the standard calls for el , index, arr your team members will be happy to see el
Robert Richey
@0x0936
Sep 08 2015 02:35
it's like arguing whether for loops should use i or index. The convention is the abstraction, i. There is a time and place for well named variables.
Vince
@Vince33
Sep 08 2015 02:36
no i is pretty standard
Robert Richey
@0x0936
Sep 08 2015 02:36
yes, and it is an abstraction
Vince
@Vince33
Sep 08 2015 02:36
yes i agree but an agreed upon one
its convention
Robert Richey
@0x0936
Sep 08 2015 02:36
beginners don't understand convention
Vince
@Vince33
Sep 08 2015 02:37
either do intermediates sometimes
making it a mess to go back and clean up there cod3
code
Robert Richey
@0x0936
Sep 08 2015 02:37
no doubt :)
Austin Lin
@austinylin
Sep 08 2015 02:38
That is why big projects/frameworks have coding standards and tools to help enforce them.
Robert Richey
@0x0936
Sep 08 2015 02:40
yep, style guides that include formatting, variable naming standards, capitalization rules, etc.
Vince
@Vince33
Sep 08 2015 02:40
I have run into poorly documented, code that looked like it had been written by a minifier as legacy and it is not fun
Rex Schrader
@SaintPeter
Sep 08 2015 02:41
There are also "linter" programs which will enforce coding standards "as you go"
Robert Richey
@0x0936
Sep 08 2015 02:47
I almost feel bad that I've prided myself on trying to, purposefully, hand-write minified javascript - non-production code! just fun stuff
Vince
@Vince33
Sep 08 2015 02:47
Yeah that stuff is great , I wish everyone used them or some kind of convention but as part of a team that has inherited a funky code base I have had the pleasure of dealing with the result of not using them , there fore I am now a evangilist for them
Austin Lin
@austinylin
Sep 08 2015 02:48
+1 a thousand times. Don’t have coding standards w/o a linter
Rex Schrader
@SaintPeter
Sep 08 2015 02:48
@0x0936 You are a bad person and should feel bad ;)
Vince
@Vince33
Sep 08 2015 02:48
hahah no just write clear code if you want happy team members lol
Robert Richey
@0x0936
Sep 08 2015 02:49

@0x0936 can I @ myself? lol

img

:)
Vince
@Vince33
Sep 08 2015 02:50
love it
thanks @0x0936
CamperBot
@camperbot
Sep 08 2015 02:51
vince33 sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star: 118 | @0x0936 | http://www.freecodecamp.com/0x0936
Rex Schrader
@SaintPeter
Sep 08 2015 02:52
@0x0936 Thanks for the laugh :D
CamperBot
@camperbot
Sep 08 2015 02:52
saintpeter sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star: 119 | @0x0936 | http://www.freecodecamp.com/0x0936
Vince
@Vince33
Sep 08 2015 02:53
what are brownie points I have not been to FCC in a long time
Rex Schrader
@SaintPeter
Sep 08 2015 02:54
wiki brownie
CamperBot
@camperbot
Sep 08 2015 02:54

:point_right: brownie points [wiki]

The number beside your picture on Free Code Camp tells you how many Brownie Points you have.

A user profile picture next to a with Brownie Points score

There are three ways you can get Brownie Points:

  1. Complete challenges - you get one point per challenge you complete
  2. Post relevant links on Camper News - you get 1 point for posting a link, and another point for each upvote your link gets
  3. Help other campers in chat - each time you help another camper and they thank you (by typing "thanks @yourname"), you will get a point

Brownie Points help you look like the kind of person who codes a lot, shares relevant links, and helps people.

They also add to your Streak.
:pencil: read more about brownie points on the FCC Wiki

Rex Schrader
@SaintPeter
Sep 08 2015 02:54
@Vince33 I never knew they had a name until @camperbot came around.
MrDrBird
@MrDrBird
Sep 08 2015 02:55
is there a difference between 'for (var i in arr)' and 'for (var i = 0; i < arr.length; i++)' ?
Vince
@Vince33
Sep 08 2015 02:56
hah @SaintPeter that camper bot got smarter since i was here last
ux4u
@ux4u
Sep 08 2015 02:57
I am stuck on a problem. I have pretty much found my way all the way through and I'm googling the heck out of this one now. I would really appreciate any help anyone could share with me. It's a Javascript issue on the number 5 waypoint. Check the Length Property of a String Variable. How do I code this?
Austin Lin
@austinylin
Sep 08 2015 02:57
@MrDrBird In that format not really. The second syntax is helpful if you are trying to do something more complicated. I usually use the first version for just iterating over an array.
Rex Schrader
@SaintPeter
Sep 08 2015 02:58
@MrDrBird Well, for..in loops are not guranteed to be in any particular order. They can be handy for somethings, but . . . I dunno, I never use 'em
@ux4u str.length
Vince
@Vince33
Sep 08 2015 02:58
@MrDrBird the "for in" loop is usually used to iterate over properties of an object
Robert Richey
@0x0936
Sep 08 2015 02:58
@MrDrBird for (var key in object) { /* ... */ }
Austin Lin
@austinylin
Sep 08 2015 03:00
Good point @SaintPeter. Another option is for..of, but it’s pretty new: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of#Browser_compatibility.
Rex Schrader
@SaintPeter
Sep 08 2015 03:00
@MrDrBird From the MDN Page:
Note: for...in should not be used to iterate over an Array where the index order is important.
ux4u
@ux4u
Sep 08 2015 03:01
@SaintPeter how do i get javascript to return the length value on the next line?
Rex Schrader
@SaintPeter
Sep 08 2015 03:01
@ux4u return str.length;
MrDrBird
@MrDrBird
Sep 08 2015 03:01
cool. thanks for the clarification @SaintPeter
CamperBot
@camperbot
Sep 08 2015 03:01
mrdrbird sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 538 | @saintpeter | http://www.freecodecamp.com/saintpeter
ux4u
@ux4u
Sep 08 2015 03:02
@SaintPeter thank you
CamperBot
@camperbot
Sep 08 2015 03:02
ux4u sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 539 | @saintpeter | http://www.freecodecamp.com/saintpeter
Rafael Castano
@PrinceJudah85
Sep 08 2015 03:03
sorry for such a noob question but, how do I apply 2 different CSS classes to 1 img element?
Rex Schrader
@SaintPeter
Sep 08 2015 03:03
@ux4u Just to break it down for you: All strings have the property length, so anyStringObject.length will return the length of the string. In order to return a value from a funciton, you're using return - so you could say return 1 or something to return that value.
@PrinceJudah85 You can add as many classes as you want by seperating them by spaces:
class="class1 class2 class3"
Rafael Castano
@PrinceJudah85
Sep 08 2015 03:04
ok. I'll try that. thanks
CamperBot
@camperbot
Sep 08 2015 03:04
if you want to thank someone, put an @ before their name!
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 03:05
sigh, what to work on when my brain starts feeling the strain
Rex Schrader
@SaintPeter
Sep 08 2015 03:05
@JoelMSwensen Angry Birds.
ux4u
@ux4u
Sep 08 2015 03:05
@SaintPeter that makes a lot more sense, thank you
CamperBot
@camperbot
Sep 08 2015 03:05
ux4u sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:warning: ux4u already gave saintpeter points
Rafael Castano
@PrinceJudah85
Sep 08 2015 03:05
it worked. Thanks @SaintPeter
CamperBot
@camperbot
Sep 08 2015 03:05
princejudah85 sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 03:05
@SaintPeter or Siffle and Olly reruns :D
CamperBot
@camperbot
Sep 08 2015 03:05
:star: 540 | @saintpeter | http://www.freecodecamp.com/saintpeter
Joel M. Swensen
@JoelMSwensen
Sep 08 2015 03:07
orrrr, finish the css and bootstrap stuff they put up since last I was here
Robert Richey
@0x0936
Sep 08 2015 03:07
I've recently had access to Netflix and have been binge watching House of Cards when I don't feel like coding
Austin Lin
@austinylin
Sep 08 2015 03:08
+1 for House of Cards
or if you are feeling old school, The West Wing
Rex Schrader
@SaintPeter
Sep 08 2015 03:09
@0x0936 Haha, I did the same then . . . then I ran out of them. Now I help out on the chat rooms for my procrastination :D
Robert Richey
@0x0936
Sep 08 2015 03:09
definitely West Wing. I've see most of those episodes as well
@SaintPeter lol :)
kgoode517
@kgoode517
Sep 08 2015 03:11
So I was wondering does anyone have any general advice for someone that is getting absolutly pummled by even the basic bonfires? Im dying out here.
Daulis Gonzalez
@Daulisg
Sep 08 2015 03:11
hi everyone!!! i'm trying to complete the Bonfire:Palindromes challenge but got stuck!! anyone available to help?
Austin Lin
@austinylin
Sep 08 2015 03:12
@Daulisg Can you paste in what you have?
Rex Schrader
@SaintPeter
Sep 08 2015 03:12
@Daulisg I can help - which one and do you have code?
Austin Lin
@austinylin
Sep 08 2015 03:12
@kgoode517 There are usually folks in here to help, just let us know which one you are working on and paste in any code you have written.
Rex Schrader
@SaintPeter
Sep 08 2015 03:13
@kgoode517 Keep plugging! I won't say it gets easier, because it doesn't. But you DO get better. Go back and look at some of the ealier Bonfires and see if they look any easier to you now. Even if they don't, by the time you get through Functional Programming, you'll be able to go back and redo some with the FP style. Suddently you 20 line monstrosity will be 4 lines of clean elegent code. It's totalyl sweet.
kgoode517
@kgoode517
Sep 08 2015 03:15
@SaintPeter Thank you I will keep trying and post my ugly broken code on here when I need to you have been very helpful.
CamperBot
@camperbot
Sep 08 2015 03:15
kgoode517 sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:warning: kgoode517 already gave saintpeter points
Daulis Gonzalez
@Daulisg
Sep 08 2015 03:15

@austinylin @SaintPeter im just a bit confused on how i need to reverse the strings:

function palindrome(str) {
// Good luck!
str.toLowerCase();

return true;
}

palindrome("eye");

Austin Lin
@austinylin
Sep 08 2015 03:16
@Daulisg The basic goal here is to convert the string into an array, reverse the array, and then convert it back to a string.
bf palindrome
CamperBot
@camperbot
Sep 08 2015 03:17

:fire:Bonfire: Check for Palindromes :link:

function palindrome(str) {
  // Good luck!
  return true;
}



palindrome("eye");

Return true if the given string is a palindrome. Otherwise, return false.

more info:  bf details | bf links | hint

Austin Lin
@austinylin
Sep 08 2015 03:17
bf links
Austin Lin
@austinylin
Sep 08 2015 03:17
@Daulisg I would look at these links:
Robert Richey
@0x0936
Sep 08 2015 03:17
@kgoode517 bonfires can be ridiculously hard without understanding functional programming. Which, for now, mostly means understanding Array.prototype.map(), filter(), reduce().
Rex Schrader
@SaintPeter
Sep 08 2015 03:17
@kgoode517 Remember: You're going to suck. That's TOTALLY FINE. Everyone sucks to start with. Their code just STINKS. Give yourself permission to stink and move along, move along. It's all part of the learning process. If you were learning to paint, no one would expect da vinci, right? Even once you're good, your old code will still look ugly to you. Trust me, I've been programming for ~20 years and even code a few years old looks bad to me . . . becuase you're always learning, always getting better.
Austin Lin
@austinylin
Sep 08 2015 03:18
+1
Daulis Gonzalez
@Daulisg
Sep 08 2015 03:19
@austinylin thanks for the links...!
CamperBot
@camperbot
Sep 08 2015 03:19
daulisg sends brownie points to @austinylin :sparkles: :thumbsup: :sparkles:
:star: 55 | @austinylin | http://www.freecodecamp.com/austinylin
kgoode517
@kgoode517
Sep 08 2015 03:20
@0x0936 Is there any other good resources to learn function programming? I have been through several courses like this where I feel the diffculty goes from changing a lightblub to curing cacer.
Robert Richey
@0x0936
Sep 08 2015 03:21

a 20 year vet? I've but a few un-productive years under my belt.

wayne

Rex Schrader
@SaintPeter
Sep 08 2015 03:21
@kgoode517 I actually encourage you to finish up the bonfires without doing Functional Programming. I disagree that they are "rediciously" hard with out it and they really only make sense in the context of doing it the "normal" way.
Austin Lin
@austinylin
Sep 08 2015 03:22
@kgoode517 One strategy I would suggest is to map out what your function needs to do in plain english or psudocode before you try to actually write the javascript. It helps to have a mental map of where you are going.
Rex Schrader
@SaintPeter
Sep 08 2015 03:22
@0x0936 20 years as a hobbyist. :) I am an electrical engineer, not a programmer, but I hope to become a professional web developer once I finish FCC
kgoode517
@kgoode517
Sep 08 2015 03:22
@SaintPeter Then thats what I will do thank you!
CamperBot
@camperbot
Sep 08 2015 03:22
kgoode517 sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:warning: kgoode517 already gave saintpeter points
Rex Schrader
@SaintPeter
Sep 08 2015 03:23
License to Stink.png
@kgoode517 For you ^^
Austin Lin
@austinylin
Sep 08 2015 03:23
lol
kgoode517
@kgoode517
Sep 08 2015 03:24
@SaintPeter Haha Ill keep that in my wallet right next to my drivers license and picture of my wife.
Robert Richey
@0x0936
Sep 08 2015 03:24
my argument for being hard without FP simply means that it's more likely to use nested looping - which, is harder to understand than FP. Which then necessitates pseudo code, as @austinylin points out. Write out in plain English what your code needs to do, then write the code
Ed Sztukowski
@Burgustu
Sep 08 2015 03:25
is it normal to feel pretty overwhelmed when you're first getting into the bonfires?
I feel way lost
Robert Richey
@0x0936
Sep 08 2015 03:25
Yes @Burgustu
Rex Schrader
@SaintPeter
Sep 08 2015 03:25
@Burgustu Yup. They're where the rubber meets the road. :D
Ed Sztukowski
@Burgustu
Sep 08 2015 03:25
yeah no kidding
Robert Richey
@0x0936
Sep 08 2015 03:29
As an example, I couldn't figure out a way to solve 'where art thou' with FP - so, I had to use nested looping, which was far harder to reason about - after already knowing FP.
Robert Richey
@0x0936
Sep 08 2015 03:35
probably because I don't fully grasp FP - but, that's OK. I accept that I'm always learning and will forever be a noob in some regards.
Ed Sztukowski
@Burgustu
Sep 08 2015 03:37
God I feel like I just need to redo the javascript section before doing this
All of these bonfires have stumped me
im just on the third
Rex Schrader
@SaintPeter
Sep 08 2015 03:40
@Burgustu Totally normal. As long as you're working them and you think you really understand how you ultimately solve them, you're good. If you are a bit iffy, feel free to ask someone to explain your own solution to you.
Layla
@laylar
Sep 08 2015 03:41
I really struggled with and finally just managed to pull through 'where art thou' with some help, but I'm struggling to get .filter to be useful for seek and destroy. =/ I used nested loops and an if statement with 'where art thou', and didn't use .filter. Currently, I've attempted to put a for loop inside the function for .filter, but it doesn't seem to be running more than once. =( Any suggestions?
Rex Schrader
@SaintPeter
Sep 08 2015 03:41
@laylar Rather than a loop inside filter (which is potentially a valid solution), how about using Array.indexOf?
Ed Sztukowski
@Burgustu
Sep 08 2015 03:42
It makes me feel better knowing that it's normal
Layla
@laylar
Sep 08 2015 03:42
@SaintPeter Thank you, I will try that.
CamperBot
@camperbot
Sep 08 2015 03:42
laylar sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 543 | @saintpeter | http://www.freecodecamp.com/saintpeter
Rex Schrader
@SaintPeter
Sep 08 2015 03:43
@laylar If you want to share your code anyway, I'm happy to look and see if you made any horrible/obvious mistakes :D
Layla
@laylar
Sep 08 2015 03:44
@Burgustu I've been stop and go the whole way... something that has helped me a bit is to take a break and work on other algorithm problems, like at codewars.com, and then come back after working with something that relates.

function destroyer(arr) {
// Remove all the values
var toFilter = arguments[0]
console.log("toFilter is: " + toFilter);
var toDestroy = [];

for(i=1; i<arguments.length; i++){
toDestroy.push(arguments[i]);
}
console.log("toDestroy is: " + toDestroy);
function isNotToBeDestroyed(value){
for(var j = 0; j < toDestroy.length; j++){
var destroying = toDestroy[j]
return value != destroying;
console.log(toDestroy[j])
}

}
  var filtered = toFilter.filter(isNotToBeDestroyed);    

console.log(filtered);
return filtered;
}

Shoot... how do I submit it formatted? =/
Austin Lin
@austinylin
Sep 08 2015 03:45
help format
CamperBot
@camperbot
Sep 08 2015 03:45

:point_right: code formatting [wiki]

Inline code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

Code Block

```js ⇦ Type 3 backticks, then type js or html and then press [shift + enter ⏎]

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Layla
@laylar
Sep 08 2015 03:45

`function destroyer(arr) {
// Remove all the values
var toFilter = arguments[0]
console.log("toFilter is: " + toFilter);
var toDestroy = [];

for(i=1; i<arguments.length; i++){
toDestroy.push(arguments[i]);
}
console.log("toDestroy is: " + toDestroy);
function isNotToBeDestroyed(value){
for(var j = 0; j < toDestroy.length; j++){
var destroying = toDestroy[j]
return value != destroying;
console.log(toDestroy[j])
}

}
  var filtered = toFilter.filter(isNotToBeDestroyed);    

console.log(filtered);
return filtered;
}

`function destroyer(arr) {
// Remove all the values
var toFilter = arguments[0]
console.log("toFilter is: " + toFilter);
var toDestroy = [];

for(i=1; i<arguments.length; i++){
toDestroy.push(arguments[i]);
}
console.log("toDestroy is: " + toDestroy);
function isNotToBeDestroyed(value){
for(var j = 0; j < toDestroy.length; j++){
var destroying = toDestroy[j]
return value != destroying;
console.log(toDestroy[j])
}

}
  var filtered = toFilter.filter(isNotToBeDestroyed);    

console.log(filtered);
return filtered;
}`

Er... sorry.
Austin Lin
@austinylin
Sep 08 2015 03:46
You need 3 backticks for a block of code and they need to be on their own line.
Layla
@laylar
Sep 08 2015 03:46

```jsfunction destroyer(arr) {
// Remove all the values
var toFilter = arguments[0]
console.log("toFilter is: " + toFilter);
var toDestroy = [];

for(i=1; i<arguments.length; i++){
toDestroy.push(arguments[i]);
}
console.log("toDestroy is: " + toDestroy);
function isNotToBeDestroyed(value){
for(var j = 0; j < toDestroy.length; j++){
var destroying = toDestroy[j]
return value != destroying;
console.log(toDestroy[j])
}

}
  var filtered = toFilter.filter(isNotToBeDestroyed);    

console.log(filtered);
return filtered;
}```

Austin Lin
@austinylin
Sep 08 2015 03:46
It’s weird but you get used to it after a while.
Layla
@laylar
Sep 08 2015 03:46
Dang. That didn't work either. <.<
Austin Lin
@austinylin
Sep 08 2015 03:46
Try them on their own line
Layla
@laylar
Sep 08 2015 03:47
function destroyer(arr) {
  // Remove all the values
  var toFilter = arguments[0]
console.log("toFilter is: " + toFilter);
  var toDestroy = [];


  for(i=1; i<arguments.length; i++){
      toDestroy.push(arguments[i]);
  }
console.log("toDestroy is: " + toDestroy);
    function isNotToBeDestroyed(value){
        for(var j = 0; j < toDestroy.length; j++){
            var destroying = toDestroy[j]
            return value != destroying;
            console.log(toDestroy[j])
        }

    }
      var filtered = toFilter.filter(isNotToBeDestroyed);    

 console.log(filtered);
    return filtered;
}
Rex Schrader
@SaintPeter
Sep 08 2015 03:47
@laylar Yay!
Austin Lin
@austinylin
Sep 08 2015 03:47
:+1:
Layla
@laylar
Sep 08 2015 03:48
Aha! =)
Austin Lin
@austinylin
Sep 08 2015 03:48
@laylar first thing here is you don’t want to nest functions, so you need to pull isNotToBeDestroyed out of destroyer, you’ll need to tweak it so you can still access toDestroy
Rex Schrader
@SaintPeter
Sep 08 2015 03:49
@laylar ok, you are REALLY close. Remember this: return exists the function it is in IMMEDIATELY. That means that you will only ever go through the first loop of your isNotToBeDestroyed - if you hit a 'to be destoryed' on the first loop, that works, but not for the second item.
Layla
@laylar
Sep 08 2015 03:50
Ohh... so if I move the return out of the for loop, it might finish the loop?
Gonna go try that.
Austin Lin
@austinylin
Sep 08 2015 03:50
@laylar take back what I said
Rex Schrader
@SaintPeter
Sep 08 2015 03:51
@laylar Something like that. You need to think about when you return false and when you return true, because they're going to be at different relative times - one would be inside the loop, one outside.
Austin Lin
@austinylin
Sep 08 2015 03:52

@laylar What you actually want to do here is use an anonymous function, like this:

array.filter(function (e) {
\\do stuff
});

That will let you still use toDestroy but not nest the functions.

Rex Schrader
@SaintPeter
Sep 08 2015 03:52
@laylar Or you can look at Array.indexOf and bypass the question - but I think it would be a good exercise for you to fix your current code before you try indexOf
Austin Lin
@austinylin
Sep 08 2015 03:52
@SaintPeter isn’t the return statement there fine because its a callback for filter.
Rex Schrader
@SaintPeter
Sep 08 2015 03:53
@austinylin What he is doing is a prefectly valid method. It's maybe not the cleanest, code wise, but this is not a contest for clean code. The key thing is the underlying logic.
Austin Lin
@austinylin
Sep 08 2015 03:53
@SaintPeter fair point.
Rex Schrader
@SaintPeter
Sep 08 2015 03:53
@austinylin It is from a technical standpoint, but from a logical standpoint it breaks his loop.
Austin Lin
@austinylin
Sep 08 2015 03:53
@SaintPeter ah, yep.
Rex Schrader
@SaintPeter
Sep 08 2015 03:54
@austinylin "Premature optimization is the root of all evil"
Austin Lin
@austinylin
Sep 08 2015 03:54
:smile: true
Rex Schrader
@SaintPeter
Sep 08 2015 03:54
@austinylin Which is not to say that you shouldn't write clean code, but you can always go back and clean it up once you know how it actually works.
Robert Richey
@0x0936
Sep 08 2015 03:58
The folks at Star Citizen agree. Ship working code, then bugfix / optimize over time. Perfect takes too much time.
I guess don't read too much into that if you've been waiting for Star Marine for forever. That misses the forest for the trees.
Cristián Berríos
@crisberrios
Sep 08 2015 04:06
Also, it's not like you have to neglect performance from the start
like making everything a decimal value in SQL/.NET or making everything a string and then parsing into whatever value you need
or just doing an endless nesting of for statements instead of spending a fair amount of time trying to come up with a proper algorithm
Jesse
@jctm30
Sep 08 2015 04:07
Hi Guys, I'm doing the "mutations" bonfire. What am I missing here?
function mutation(arr) {
  var indices = [];
  var firstArray = arr[0].toString;
  var newFirstarray = firstArray.split('');
  var secondArray = arr[1].toString;
  var element = secondArray.split('');
  var idx = newFirstarray.indexOf(element);
  while (idx != -1) {
    indices.push(idx);  
  }  
  if (indices.length >= secondArray.length) {
    return true;
  }
  else {
    return false;
  }
}

mutation(['hello', 'hey']);
DTing
@dting
Sep 08 2015 04:08
@jctm30 you never change idx in your loop
that will just run forever
Jesse
@jctm30
Sep 08 2015 04:10

@dting i'm getting the error message that

firstArray.split('');

is not a function

DTing
@dting
Sep 08 2015 04:12
your element in arr is already a string
you are actually returning the toString function of the Stringinstance
Jesse
@jctm30
Sep 08 2015 04:13
@dting oh ok got cha. I'm sorry
what'd you mean by changing idx?
DTing
@dting
Sep 08 2015 04:13
if you want you could call .toString() (notice the paranthesis) of the arr[0] but it will just return the string in this case.
right now if you enter that loop with idx != -1
what would cause that loop to stop looping?
you also are declaring var element = secondArray.split('');
and you also are declaring var newFirstarray = firstArray.split('');
then you var idx = newFirstarr.indexOf(element);
unless your newFirstarray contains an array that will always be -1 i think.
Boobooy
@Boobooy
Sep 08 2015 04:46

Hi, I'm doing Bonfire: Reverse a String. I manage to get the test result requested but the program won't let me advance and still said that the tasks are not completed. Not sure what I missed. Can anybody help? Here is the code that I wrote:

function reverseString(str) {
return str;
}

reverseString('Greetings from Earth Howdy hello').split('').reverse().join('');

DTing
@dting
Sep 08 2015 04:48
The code should go inside the function
the tests calls the reverseString function.
right now your reverseString function just returns the original string.
Boobooy
@Boobooy
Sep 08 2015 04:55
I see. No wonder it wouldn't let me advance. Now my code doesn't work when I put it into a function. Can you give me any hints on how to solve this?
DTing
@dting
Sep 08 2015 05:00
what does your code look like now?
Boobooy
@Boobooy
Sep 08 2015 05:05

Now it doesn't do anything. It looks like this:

function reverseString(str) {

str.split('').reverse().join('');

return str;
}
reverseString('hello');

DTing
@dting
Sep 08 2015 05:05
strings are immutable
str.split does not change what str is.
rather it returns a value
wiki immutable
CamperBot
@camperbot
Sep 08 2015 05:05

:point_right: js immutable [wiki]

Immutable means unchangeable i.e. you can't change.

Javascript has lots of immutable types e.g. string primitive type. Try this in your console.

s = "red";
console.log(s[1]); //→ "e"
s[1] = "x";
console.log(s) //→ "red"

the s didn't change! WAT!

:pencil: read more about js immutable on the FCC Wiki

DTing
@dting
Sep 08 2015 05:06
so you either need to assign the result to something or return the result.
Terrell Vest
@MirPresT
Sep 08 2015 05:08
anyone need assistance with something they are working on? I have some down time and am open to see If I can assist, let me know, I'll see if I can help -
Boobooy
@Boobooy
Sep 08 2015 05:11
Thanks for the explanation, dting. I'm still unclear on how to solve it though. I thought the reversestring function is just to declare that whatever I put inside the function will become a string due to the parameters inside the function. That's the reason I put the code outside of the function. I guess I need to do more research on how to solve a reverseString inside the function.
CamperBot
@camperbot
Sep 08 2015 05:11
if you want to thank someone, put an @ before their name!
Boobooy
@Boobooy
Sep 08 2015 05:12
Thanks @dting
CamperBot
@camperbot
Sep 08 2015 05:12
boobooy sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1045 | @dting | http://www.freecodecamp.com/dting
DTing
@dting
Sep 08 2015 05:12
@Boobooy you are really close
you actually have solved it. you just aren't returning the solution
you are still returning the original string str
Boobooy
@Boobooy
Sep 08 2015 05:22
Can you show me how to put the code inside the function, Dting? I'm still lost on the logic of the function.
Hans van Riet
@hansinla
Sep 08 2015 05:26
@Boobooy Your str.split('').reverse().join(''); returns your answer, but you’re not doing anything with it. Instead you return str which hasn’t been altered.
<style>
  body {
    background-color: black;
  }

   .green-text {
    color: green;
  }
    .p {
    font-family: Monospace;
  }

</style>
<h1 class = "green-text p">Hello World</h1>
Give your body element the color property of green.
Give your body element the font-family property of Monospace.
What am i missing here ? how to cover the above 2 points ?
DTing
@dting
Sep 08 2015 05:29
.p is the class p
Hans van Riet
@hansinla
Sep 08 2015 05:30
@manojmurli currently you give the p class Monospace and the body a black background-color
DTing
@dting
Sep 08 2015 05:30
they also want all your styles as part of the body styles
Screen Shot 2015-09-07 at 10.30.58 PM.png
follow those directions
specifically the 4th and 5th one
Boobooy
@Boobooy
Sep 08 2015 05:34
Thanks @hansinla . I finally manage to get it to work.
CamperBot
@camperbot
Sep 08 2015 05:34
boobooy sends brownie points to @hansinla :sparkles: :thumbsup: :sparkles:
:star: 351 | @hansinla | http://www.freecodecamp.com/hansinla
MANOJ MURALI
@manojmurli
Sep 08 2015 05:34
@dting & @hansinla thx .. corrected the code
CamperBot
@camperbot
Sep 08 2015 05:34
manojmurli sends brownie points to @dting and @hansinla :sparkles: :thumbsup: :sparkles:
:star: 352 | @hansinla | http://www.freecodecamp.com/hansinla
:star: 1046 | @dting | http://www.freecodecamp.com/dting
winstonlan
@winstonlan
Sep 08 2015 05:41
Bonfire: Mutations
CamperBot
@camperbot
Sep 08 2015 05:41

:fire:Bonfire: Mutations :link:

function mutation(arr) {
  return arr;
}

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

Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.

more info:  bf details | bf links | hint

winstonlan
@winstonlan
Sep 08 2015 05:41
hint
CamperBot
@camperbot
Sep 08 2015 05:41
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
MANOJ MURALI
@manojmurli
Sep 08 2015 05:45
how does this camperbot work ?
should we copy paste the waypoint challenge name ?
Rex Schrader
@SaintPeter
Sep 08 2015 05:46
@manojmurli What are you trying to do?
Dhananjay Mehrotra
@dj8923
Sep 08 2015 05:46
var args = Array.prototype.slice.call(arguments); why is it suggested that we should construct a new array by iterating through the arguments object rather than doing slice ,ethod??
*method
Rex Schrader
@SaintPeter
Sep 08 2015 05:47
@dj8923 There are optimization implications. You can see more detail on the full Wiki page.
wiki arguments
CamperBot
@camperbot
Sep 08 2015 05:47

:point_right: bonfire arguments optional [wiki]

Explanation:

It can be quite complicated to understand what needs to be done. There is always many ways to do something when coding but regardless of the algorithm used, we have to create a program that does the following:

  • It has to add two numbers passed as parameters and return the addition.
  • It has to check if any of the numbers are actual numbers, otherwise return undefined and stop the program right there.
  • It has to check if it has one or two arguments passed. More re ignored.
  • If it has only one then it has to return a function that used that number and expects another one, to then add it.

:pencil: read more about bonfire arguments optional on the FCC Wiki

Rex Schrader
@SaintPeter
Sep 08 2015 05:47
wiki js arguments
CamperBot
@camperbot
Sep 08 2015 05:47

:point_right: js arguments [wiki]

The arguments object is an array-like object (meaning that it looks like an array but it's not) that stores all of the arguments that you passed to a function and is proprietary to that function in particular. If you were to pass 3 arguments to a function, say storeNames(), those 3 arguments would be stored inside an object called arguments and it would look like this when we pass the arguments storeNames("Mulder", "Scully", "Alex Krycek") to our function:

  • First, we declare a function and make it return the arguments object.

    function storeNames() { return arguments; }
  • Then, when we execute that function with n arguments, 3 in this case, it will return the object to us and it will look like an array. We can convert it to an array, but more on that later...

    // If we execute the following line in the console:
    storeNames("Mulder", "Scully", "Alex Kryceck");
    // The output will be: ["Mulder", "Scully", "Alex Kryceck"]

If you want to know more about this, such as converting it to an array or the optimization problem that comes with using the slice() method and how to solve it, click on read more (Gitter Chat Only).

:pencil: read more about js arguments on the FCC Wiki

Rex Schrader
@SaintPeter
Sep 08 2015 05:48
@dj8923 Click through the Wiki article and there is more detail than you can shake a stick at.
MANOJ MURALI
@manojmurli
Sep 08 2015 05:49
Waypoint: Override Class Declarations by Styling ID Attributes
<style>
  body {
    background-color: black;
    font-family: Monospace;
    color: green;
  }
  .pink-text {
    color: pink;
  }
  .blue-text {
    color: blue;
  }
  .orange-text {
    color: orange;
  }
</style>
<h1 class="pink-text blue-text">Hello World!</h1>
Rex Schrader
@SaintPeter
Sep 08 2015 05:50
@manojmurli Do you know how to add an id attribute to the h1 element?
Shannon
@shannonfears
Sep 08 2015 06:10
Hi kids, for a couple of reasons I plunged into a bonfire
As I was saying ... "Reverse a string" ... by myself. Drove me damn near nuts. Finally gave up and looked up the answer. OK, I know the answer. Now I want to know the thinking behind it. For starters, I know how to define a variable, but I didn't think to do that in this case. I was trying to do str.split(""); all by itself. But the real mind-blower was finding out you could do the split, reverse and join all on the same line. Anyone care to comment?
DTing
@dting
Sep 08 2015 06:16
@shannonfears strings are immutable
wiki immutable
CamperBot
@camperbot
Sep 08 2015 06:16

:point_right: js immutable [wiki]

Immutable means unchangeable i.e. you can't change.

Javascript has lots of immutable types e.g. string primitive type. Try this in your console.

s = "red";
console.log(s[1]); //→ "e"
s[1] = "x";
console.log(s) //→ "red"

the s didn't change! WAT!

:pencil: read more about js immutable on the FCC Wiki

DTing
@dting
Sep 08 2015 06:16
the String.split function returns an array
it doesnt change the actual variable
because str.split('') returns an array. Array instances have a function called "reverse".
that you can call that will reverse the array
this actually changes the array. but in addition to that it also returns a reference to itself.
because it does this, you can chain another function call using another function of array instances. .join(''). The join function also does not change the array, rather like String.split it returns a string that is joined, separated by the separator argument.
not sure if that helps
Shannon
@shannonfears
Sep 08 2015 06:22
I pretty much understood all of that at the outset, except for chaining the functions together.
My big problem so far is that I scoot through the waypoints without a whole lot of problem but when left to figure out a bonfire I can't think of the correct first step.
I know I'm supposed to pair these but I'm using Linux which of codes I can't use Screenhero on. So I thought I'd try the first couple by myself.
But I appreciate your explanation.
DTing
@dting
Sep 08 2015 06:25
I actually wonder how many people pair for these. I'm guessing the number is rather small because there are a lot of issues with screen hero
Shannon
@shannonfears
Sep 08 2015 06:27
So let me ask this: What should have clued me in to the idea to initialize a variable first?
DTing
@dting
Sep 08 2015 06:28
what solution are you refering to? you dont need to do that you can just return the value of the chained function calls too
function reverseString(str) {
    return str.split('').reverse().join('');
}
the jump to be made is that str isnt mutable. so the result has to be assigned to something or returned from the function.
or used

if you have

function reverseString(str) {
    str.split('').reverse().join('');
    return str;
}

and you know that strings aren't mutable. and string wasn't assigned another value. then you know that you will be returning the original value of str

gogu87
@gogu87
Sep 08 2015 06:30
hi, i got one question. Is http://www.freecodecamp.com/challenges/waypoint-give-your-javascript-slot-machine-some-stylish-images bugged or am i not doing something right with my answer, which is: $($('.slot')[0]).html("<img src='" + images[slotOne-1]+ "'>");
$($('.slot')[1]).html("<img src='" + images[slotTwo-1]+ "'>");
$($('.slot')[2]).html("<img src='" + images[slotThree-1]+ "'>");
Shannon
@shannonfears
Sep 08 2015 06:31
OK, I understand that. There's a Github bot for this bonfire that links to this page:
Great, can't paste the URL. Not my night! But I get it now, and I thank you.
CamperBot
@camperbot
Sep 08 2015 06:33
if you want to thank someone, put an @ before their name!
DTing
@dting
Sep 08 2015 06:34
np
Christopher Hinojosa
@Draxell
Sep 08 2015 06:55
Hey guys, can someone help me with the first zipline?
Aleksandr Sidorov
@AleksandrSidorov
Sep 08 2015 06:55
Hello, everybody! I
Christopher Hinojosa
@Draxell
Sep 08 2015 06:55
Hi
Aleksandr Sidorov
@AleksandrSidorov
Sep 08 2015 06:56
I'm working on Quote Machine. forismatic.com API if more cpecific.
Christopher Hinojosa
@Draxell
Sep 08 2015 06:56
have you done the portfolio zipline?
Aleksandr Sidorov
@AleksandrSidorov
Sep 08 2015 06:57
Almot done, but not submit yet. I want at least one cmpleted project in "projects" cection :)
Christopher Hinojosa
@Draxell
Sep 08 2015 06:58
I'm having a problem with mine, would you be able to help me?
Aleksandr Sidorov
@AleksandrSidorov
Sep 08 2015 06:58
Yes I would try. How can I help?
Christopher Hinojosa
@Draxell
Sep 08 2015 06:59
the contents of each section get moved into the section below it when the screen is smaller than the one I made it on
if that makes sense
I don't know how to make certain things in a fixed position within a section
Aleksandr Sidorov
@AleksandrSidorov
Sep 08 2015 07:00
can you give me a codepen link&
?
the best portion to look at as an example would be about section
it has a picture of myself
if you zoom in once it moves to the portfolio section
actually you can see it here
test
ok
can you see it?
Aleksandr Sidorov
@AleksandrSidorov
Sep 08 2015 07:04
I can see. Do you try to add "padding-bottom: 50px;" to your section div's?
Christopher Hinojosa
@Draxell
Sep 08 2015 07:05
no I didn't
so in css .section { padding-bottom: 50px;}?
Costas Chaitas
@CostasChaitas
Sep 08 2015 07:30
anyone knows good recourses to learn php?
angietek
@angietek
Sep 08 2015 07:35

<img src="https://bit.ly/fcc-relaxing-cat">

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

any idea?
Christopher Hinojosa
@Draxell
Sep 08 2015 07:43
codecademy has a php section don't they?
Mbos95
@Mbos95
Sep 08 2015 08:01
Hey guys. Would someone be able to help me with vonfire return the largest number in a array?
avatarhzh
@avatarhzh
Sep 08 2015 08:02

I'm trying to get the random quote machine to work using the forismatic API. Not sure why the code I wrote isn't picking up on the properties of the response object received

<script>
  function showQuote(response) {
  var newQuote = '';
  newQuote = '<p>/"response.quoteText/"</p>';
  newQuote += '<p>response.quoteAuthor</p>';
  document.getElementById('quote').innerHTML = newQuote;
}
</script>
<script src="http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=showQuote"></script>

My page ends up literally showing /"response.quoteText/" and response.quoteAuthor instead of the actual quote and author from the JSON

Mbos95
@Mbos95
Sep 08 2015 08:03
function largestOfFour(arr) {
  for(i = 0; i < arr.length; i++){
    arr[i]


  }

}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
How do I go through the first subarray?
marzelin
@marzelin
Sep 08 2015 08:04
@Mbos95 arguments[0]
Mbos95
@Mbos95
Sep 08 2015 08:04
@marzelin That doesn't ring any bell
avatarhzh
@avatarhzh
Sep 08 2015 08:05
@Mbos95 use two indexes for nested arrays. For example arr[0][0] would be 4, arr[0][1] would be 5 arr[0][2] would be 1 and so on and so forth
Christopher Hinojosa
@Draxell
Sep 08 2015 08:06
which bonfire is that Mbos95?
Mbos95
@Mbos95
Sep 08 2015 08:06
bonfire return largest number in arrays
CamperBot
@camperbot
Sep 08 2015 08:06
Sorry, can't find a bonfire called return largest number in arrays. [ Check the map? ]
Mbos95
@Mbos95
Sep 08 2015 08:06
bonfire Return Largest Numbers in Arrays
CamperBot
@camperbot
Sep 08 2015 08:06

:fire:Bonfire: Return Largest Numbers in Arrays :link:

function largestOfFour(arr) {
  // You can do this!
  return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays.

more info:  bf details | bf links | hint

Christopher Hinojosa
@Draxell
Sep 08 2015 08:06
kk give me a second
avatarhzh
@avatarhzh
Sep 08 2015 08:06
and for the second array use a[1][i] i being the position of the number you want in the second subarray
Mbos95
@Mbos95
Sep 08 2015 08:07
@avatarhzh That is true, but I need to use it in a for loop. If I were to put arr[0][1].length for example, it doesn't work. It'll not pick a certain array or anything
marzelin
@marzelin
Sep 08 2015 08:07
@Mbos95
arr[0].forEach(function() {
//your code here
});
avatarhzh
@avatarhzh
Sep 08 2015 08:08
to indicate the subarray just use the the first index without specifying the second index
Mbos95
@Mbos95
Sep 08 2015 08:08
@avatarhzh Can you show me in an example please?
Christopher Hinojosa
@Draxell
Sep 08 2015 08:08
yeah, you need two foreach loops or two for loops
Mbos95
@Mbos95
Sep 08 2015 08:08
@marzelin I'll look up this function.forEach
Christopher Hinojosa
@Draxell
Sep 08 2015 08:08
I would use two for loops if you're unfamiliar with forEach like I am
avatarhzh
@avatarhzh
Sep 08 2015 08:09
^
Mbos95
@Mbos95
Sep 08 2015 08:09
Yes, but can'thurt to look at it :D
Christopher Hinojosa
@Draxell
Sep 08 2015 08:09
for sure
Mbos95
@Mbos95
Sep 08 2015 08:09
I will use for loops.
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 08:09
learn how to use forEach
it will be super helpful
avatarhzh
@avatarhzh
Sep 08 2015 08:09
can someone please help me with my api problem?
Mbos95
@Mbos95
Sep 08 2015 08:09
but I need one for loop to run the certain arrays and one for loops to run the comparator and push it into a certain array with the largest numbers
Right?
to iterate through the arrays*
@DhruvPrakash Eventually :)
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 08:10
@avatarhzh try loading that api script before ur actual code instead of afterr
avatarhzh
@avatarhzh
Sep 08 2015 08:11
@DhruvPrakash so include the url by clicking the settings button in codepen and putting the url in there?
Christopher Hinojosa
@Draxell
Sep 08 2015 08:12
yes @Mbos95
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 08:12
or
<script src="http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=showQuote"></script>
<script>
  function showQuote(response) {
  var newQuote = '';
  newQuote = '<p>/"response.quoteText/"</p>';
  newQuote += '<p>response.quoteAuthor</p>';
  document.getElementById('quote').innerHTML = newQuote;
}
</script>
Mbos95
@Mbos95
Sep 08 2015 08:12
<script src="http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=showQuote"></script>
<script>
  function showQuote(response) {
  var newQuote = '';
  newQuote = '<p>/"response.quoteText/"</p>';
  newQuote += '<p>response.quoteAuthor</p>';
  document.getElementById('quote').innerHTML = newQuote;
}
@Draxell Oke. but I still don't get how to do the first for loop then. I need to iterate through 4 different subarrays. They are all 4 long. as I need to pick the largest number from every sub array i can't have any overlap. I am not sure how to do this!
jojacino
@jojacino
Sep 08 2015 08:14
Hey could someone take a look at my homepage and tell me what you think.. I spent all day re-doing the design. External links don't work yet and I have to css it for phones and tablets but I am done with the rest.
avatarhzh
@avatarhzh
Sep 08 2015 08:14
@DhruvPrakash tried that. Javascript console says the function showQuote is not defined when I do that
Mbos95
@Mbos95
Sep 08 2015 08:14
jojacino
@jojacino
Sep 08 2015 08:14
yeah
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 08:14
can u link me
to ur codepen
avatarhzh
@avatarhzh
Sep 08 2015 08:16
I'm reading the javascript book by Jon Duckett and tried changing the example in the book to fit my page and it's not working for some reason
Mbos95
@Mbos95
Sep 08 2015 08:17
@jojacino Looks good. Although the buttons aren't really centered. In your portfolio bit the black text is a bit hard to read. and the pictures in the background are abit random :D
@avatarhzh Nice background though..
avatarhzh
@avatarhzh
Sep 08 2015 08:18
thanks
CamperBot
@camperbot
Sep 08 2015 08:18
if you want to thank someone, put an @ before their name!
avatarhzh
@avatarhzh
Sep 08 2015 08:19
although I'd much rather have a ugly background and have the code working at this point lol
Mbos95
@Mbos95
Sep 08 2015 08:19
@avatarhzh I can imagine. xD
jojacino
@jojacino
Sep 08 2015 08:19
@Mbos95 Thank you for pointing that out. =D I will fix those tomorrow morning.. need zzzz's Gnight all!
CamperBot
@camperbot
Sep 08 2015 08:19
jojacino sends brownie points to @mbos95 :sparkles: :thumbsup: :sparkles:
:star: 181 | @mbos95 | http://www.freecodecamp.com/mbos95
Mbos95
@Mbos95
Sep 08 2015 08:20
@jojacino Also, clicking the portfolio things doesn't do anything. Good night!
jojacino
@jojacino
Sep 08 2015 08:20
yeah I need to do all of the @media and links stuff later
Christopher Hinojosa
@Draxell
Sep 08 2015 08:22
your first for loop is for each sub array, your second for loops looks through each sub array, if it's the largest number you push that into a new array and return the new array
@Mbos95
Mbos95
@Mbos95
Sep 08 2015 08:23
But how to loop for each subarray?
Can you show me an example please? I have been struggling with this for a while xD
Christopher Hinojosa
@Draxell
Sep 08 2015 08:24
for(var i = 0; i < arr.length; i++){
one sec
I'll copy and past an example
Mbos95
@Mbos95
Sep 08 2015 08:24
but that loops through the whole array, all subs included.
Oke, thank you @Draxell
CamperBot
@camperbot
Sep 08 2015 08:26
mbos95 sends brownie points to @draxell :sparkles: :thumbsup: :sparkles:
:star: 259 | @draxell | http://www.freecodecamp.com/draxell
Christopher Hinojosa
@Draxell
Sep 08 2015 08:26

for(var i = 0; i < arr.length; i++) {
var currArr = arr[i]
for(var j = 0; j < currArr.length; j++) {

}

}

Mbos95
@Mbos95
Sep 08 2015 08:26
So that loops through the first subarray?
Aleksandr Sidorov
@AleksandrSidorov
Sep 08 2015 08:26
Anybody solve the "Qote Machine" using the XMLHttpRequest or .getJSON? JSONP is only method worked for me.
avatarhzh
@avatarhzh
Sep 08 2015 08:26
for(var i = 0; i < arr.length; i++){
   for(var j = 0; j < arr[i].length; j++) { 
     \\Your code
}
}
Christopher Hinojosa
@Draxell
Sep 08 2015 08:27
yes that will cycle through each sub array individually
avatarhzh
@avatarhzh
Sep 08 2015 08:27
@shtil80 you can't use XML because that breaks the same origin policy
I'm still trying to get my code machine working
*quote machine
Mbos95
@Mbos95
Sep 08 2015 08:28
@Draxell Hmm oke! so then I can use a comparator for each time the for loop loops.
Aleksandr Sidorov
@AleksandrSidorov
Sep 08 2015 08:29
@avatarhzh I have read about that policy. There is a CORS spec for override that - http://www.html5rocks.com/en/tutorials/cors/
but it didn't work for forismatic.com I think.
DTing
@dting
Sep 08 2015 08:29
@shtil80 getJSON also allows you to use jsonp i have an example here: http://codepen.io/dting/pen/PqrZgb
avatarhzh
@avatarhzh
Sep 08 2015 08:30
oh true didn't know that will have a read
Aleksandr Sidorov
@AleksandrSidorov
Sep 08 2015 08:32
@avatarhzh but I can't manage it to work
avatarhzh
@avatarhzh
Sep 08 2015 08:32
@dting how come when I include this in my html, the page shows /"response.quoteText/" response.quoteAuthor instead of the actual properties of the response object?
<script>function showQuote(response) {
  var newQuote = '';
  newQuote = '<p>/"response.quoteText/"</p>';
  newQuote += '<p>response.quoteAuthor</p>';
  document.getElementById('quote').innerHTML = newQuote;
}
</script>
<script src="http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=showQuote"></script>
Aleksandr Sidorov
@AleksandrSidorov
Sep 08 2015 08:32
DTing
@dting
Sep 08 2015 08:33
you need to concat the response and the tags
Aleksandr Sidorov
@AleksandrSidorov
Sep 08 2015 08:33
@dting Nice. I'll try this.
DTing
@dting
Sep 08 2015 08:34
right now you are just making a string that equals '<p>/"response.quoteText/"</p>'
newQuote = "<p>" + response.quoteText + "</p>";
avatarhzh
@avatarhzh
Sep 08 2015 08:34
oh ok thanks @dting
CamperBot
@camperbot
Sep 08 2015 08:34
avatarhzh sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1047 | @dting | http://www.freecodecamp.com/dting
avatarhzh
@avatarhzh
Sep 08 2015 08:34
lol
Mbos95
@Mbos95
Sep 08 2015 08:37
function largestOfFour(arr) {
for(var i = 0; i < arr.length; i++) {
  var currArr = arr[i]
for(var j = 0; j < currArr.length; j++) {
   var largestnumber = [];
  if(currArr[j] > largestnumber){
     largestnumber.push(currArr[j])
   }
}
return largestnumber
}

}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Why does that return me a 3? not 5 ? xD
it is supposed to only push currArr[j] into the empty array if it i greater as current largestnumber
Aleksandr Sidorov
@AleksandrSidorov
Sep 08 2015 08:38
@dting What is JSON.stringify(response) do?
avatarhzh
@avatarhzh
Sep 08 2015 08:39
turns the object into a string
DTing
@dting
Sep 08 2015 08:39
ya
Aleksandr Sidorov
@AleksandrSidorov
Sep 08 2015 08:40
@avatarhzh @dting ok, thanks, got it
CamperBot
@camperbot
Sep 08 2015 08:40
shtil80 sends brownie points to @avatarhzh and @dting :sparkles: :thumbsup: :sparkles:
:star: 177 | @avatarhzh | http://www.freecodecamp.com/avatarhzh
:star: 1048 | @dting | http://www.freecodecamp.com/dting
Aleksandr Sidorov
@AleksandrSidorov
Sep 08 2015 08:42
@dting So there is no way to use CORS with forismatic.com API and the jsonp is only way?
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 08:43
@shtil80 sadly it seems that way
Aleksandr Sidorov
@AleksandrSidorov
Sep 08 2015 08:45
@DhruvPrakash thanks for confirm my doubts. I must stop to fight with windmills :)
CamperBot
@camperbot
Sep 08 2015 08:45
shtil80 sends brownie points to @dhruvprakash :sparkles: :thumbsup: :sparkles:
:star: 150 | @dhruvprakash | http://www.freecodecamp.com/dhruvprakash
Mbos95
@Mbos95
Sep 08 2015 08:50
function largestOfFour(arr) {
for(var i = 0; i < arr.length; i++) {
  var currArr = arr[i]
for(var j = 0; j < currArr.length; j++) {
  var localnum = currArr[j] 
  var largestnumber = [];
  if(localnum > largestnumber){
     largestnumber.push(currArr[j])
   }else{



   }
}
  return largestnumber;
}
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Why doesn't it check if it is greater as localnum before pushing it into the array? It returns 3. I think it just cycles through and not take notice of what is a higher number
@shtil80 That is an hilarious thing to say xD that made me chuckle
@shtil80 Is that an known saying ?
avatarhzh
@avatarhzh
Sep 08 2015 08:52
I think you need to separate largestnumber and what you're returning
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 08:52
@Mbos95 because ur largestNumber is an array and ur comparing it with a number
avatarhzh
@avatarhzh
Sep 08 2015 08:52
yea you're comparing an empty array with a number
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 08:53
@avatarhzh did u get ur random quote to work?
avatarhzh
@avatarhzh
Sep 08 2015 08:53
yea
Mbos95
@Mbos95
Sep 08 2015 08:53
Hmm oke. so my largestnumber should be an number.
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 08:53
awesome
i had to do some reading up too :p, Not too familiar with jsonp and stuff like that
avatarhzh
@avatarhzh
Sep 08 2015 08:53
turns out all I needed to do was concat the response's properties properly lol
Mbos95
@Mbos95
Sep 08 2015 08:53
And after comparison I can make the number go into another variable and then push that one into an array
avatarhzh
@avatarhzh
Sep 08 2015 08:53
yea
@Mbos95 try setting largestNumber to zero and declare another variable as an empty array to return
Mbos95
@Mbos95
Sep 08 2015 08:54
oke, i'll try that!
Aleksandr Sidorov
@AleksandrSidorov
Sep 08 2015 08:55
Mbos95
@Mbos95
Sep 08 2015 08:55
function largestOfFour(arr) {
for(var i = 0; i < arr.length; i++) {
  var currArr = arr[i]
for(var j = 0; j < currArr.length; j++) {
  var localnum = currArr[j] 
  var largestnumber = 0;
  var endarray = [];
  if(localnum > largestnumber){
     endarray.push(localnum)
   }else{



   }
}
  return endarray;
}
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
returns 3 :(
So localnum will carry the value of currArr[j].
largestnumber is a number now.
I have an empty array ready
I compare localnum to largestnumber. if larger, push localnum in the empty array
it returns 3 :(
@shtil80 Whats that? is it a good book ?
@shtil80 Is it full of people fighting windmills?
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 09:00
1)Declare ur endarray before the first for loop.
2) In the inner for loop just focus on finding out what the largest number is and assign that to largestnumber.
3) Before the end of the outer for loop, push largestnumber to the endarray
Mbos95
@Mbos95
Sep 08 2015 09:02
function largestOfFour(arr) {
    var endarray = [];
for(var i = 0; i < arr.length; i++) {
  var currArr = arr[i]
for(var j = 0; j < currArr.length; j++) {
  var localnum = currArr[j] 
  var largestnumber = 0;
  if(localnum > largestnumber){
     localnum = largestnumber
   }else{



   }
  endarray.push(largestnumber)
}
  return endarray;
}
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 09:02
so ur inner for loop should be something like this -
for(var j = 0; j < currArr.length; j++) {
  var localnum = currArr[j] 
  if(localnum > largestnumber){
     largestnumber = localnum;
   }
}
Mbos95
@Mbos95
Sep 08 2015 09:02
Now I have this It returns [0,0,0,0].. which is more then before.. but it just returns the 0 from largestnumber.
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 09:03
initialize ur largestnumber in the outer for loop
just before the inner one
Mbos95
@Mbos95
Sep 08 2015 09:04
What you mean with initialize? Declare it ?
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 09:04
var largestnumber = 0
Mbos95
@Mbos95
Sep 08 2015 09:05
ah oke.
Christopher Hinojosa
@Draxell
Sep 08 2015 09:05
you don't need an else statement
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 09:05
and u should do the pushing in the outer for loop, not in the inner one
the inner one just finds the largest number in the sub array u are looping.
the outer one pushes that largestnumber to the endarray
Mbos95
@Mbos95
Sep 08 2015 09:05
function largestOfFour(arr) {
    var endarray = [];
for(var i = 0; i < arr.length; i++) {
  var currArr = arr[i]
  var largestnumber = 0;
for(var j = 0; j < currArr.length; j++) {
  var localnum = currArr[j] 

  if(localnum > largestnumber){
     localnum = largestnumber
  }

  endarray.push(largestnumber)
}
  return endarray;
}
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
i HAVE IT LIKE THIS NOW
oops caps.. all panicky xD
uhh sorry, double largestnumber
Christopher Hinojosa
@Draxell
Sep 08 2015 09:06
you need to take away your second largestNumber var
Mbos95
@Mbos95
Sep 08 2015 09:07
Oke, got that one out now
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 09:07
move ur endarray.push line to where u have the return endarray
and move ur return endarray to the line just before ur final }
Mbos95
@Mbos95
Sep 08 2015 09:07
function largestOfFour(arr) {
    var endarray = [];
for(var i = 0; i < arr.length; i++) {
  var currArr = arr[i]
  var largestnumber = 0;
for(var j = 0; j < currArr.length; j++) {
  var localnum = currArr[j] 

  if(localnum > largestnumber){
     localnum = largestnumber
  }


}
  endarray.push(largestnumber)

}
  return endarray;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 09:08
yes
Mbos95
@Mbos95
Sep 08 2015 09:08
I see, got confused and thought it was in the outer for loop. stupid brackets :D
But now it still returns [0,0,0,0] sadly :(
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 09:09
thats because what ur doing in the if statement is incorrect
u are assigning localnum to largestnumber
it should be the other way
Ozy Design & Software
@OzySky
Sep 08 2015 09:09
<
Mbos95
@Mbos95
Sep 08 2015 09:10
ooooh! oke !
Stupid mistake!
Thank you so much guys!
CamperBot
@camperbot
Sep 08 2015 09:10
if you want to thank someone, put an @ before their name!
Mbos95
@Mbos95
Sep 08 2015 09:10
Thanks @DhruvPrakash @DhruvPrakash @DhruvPrakash @DhruvPrakash @Draxell @Draxell @DhruvPrakash @Draxell
CamperBot
@camperbot
Sep 08 2015 09:10
mbos95 sends brownie points to @dhruvprakash and @dhruvprakash and @dhruvprakash and @dhruvprakash and @draxell and @draxell and @dhruvprakash and @draxell :sparkles: :thumbsup: :sparkles:
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 09:10
don't mention it :)
CamperBot
@camperbot
Sep 08 2015 09:10
:warning: mbos95 already gave draxell points
:warning: mbos95 already gave draxell points
:warning: mbos95 already gave draxell points
:star: 151 | @dhruvprakash | http://www.freecodecamp.com/dhruvprakash
:star: 151 | @dhruvprakash | http://www.freecodecamp.com/dhruvprakash
:star: 151 | @dhruvprakash | http://www.freecodecamp.com/dhruvprakash
:star: 151 | @dhruvprakash | http://www.freecodecamp.com/dhruvprakash
:star: 151 | @dhruvprakash | http://www.freecodecamp.com/dhruvprakash
Mbos95
@Mbos95
Sep 08 2015 09:10
I just did xD
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 09:13
:/ I gotta start my essays. I've been procrastinating way too long
Mbos95
@Mbos95
Sep 08 2015 09:13
@DhruvPrakash I didn't mind the procrastinating xD
Good luck with your essay though
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 09:13
thanks!
CamperBot
@camperbot
Sep 08 2015 09:13
if you want to thank someone, put an @ before their name!
Dhruv Prakash
@DhruvPrakash
Sep 08 2015 09:14
@Mbos95 thanks
CamperBot
@camperbot
Sep 08 2015 09:14
dhruvprakash sends brownie points to @mbos95 :sparkles: :thumbsup: :sparkles:
:star: 183 | @mbos95 | http://www.freecodecamp.com/mbos95
Rory Smith
@alanbuchanan
Sep 08 2015 09:38
need some help with Bonfire: Smallest Common Multiple. i have an algorithm that works it out for 2 numbers but becomes harder with an array of more than 2
CamperBot
@camperbot
Sep 08 2015 09:38
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Aleksandr Sidorov
@AleksandrSidorov
Sep 08 2015 09:38
Do I need use $(document).ready()... in the codepen.io jQuery-enabled pen?
Aniruddh Agarwal
@anrddh
Sep 08 2015 09:38
@shtil80 yes
bf smallest common multiple
CamperBot
@camperbot
Sep 08 2015 09:38

:fire:Bonfire: Smallest Common Multiple :link:

function smallestCommons(arr) {
  return arr;
}


smallestCommons([1,5]);

Find the smallest number that is evenly divisible by all numbers in the provided range.

more info:  bf details | bf links | hint

Aniruddh Agarwal
@anrddh
Sep 08 2015 09:39
Ah, this is a Project Euler problem
I did this for numbers from 1 through 20 :D
Can you show me your current code?
Rory Smith
@alanbuchanan
Sep 08 2015 09:40
function smallestCommons(a, b)
{ 
    if (b == 0){
        return a;
    } else {
        return smallestCommons(b, a % b);
    }
}
it's euclid's algorithm
i need to adapt it
somehow....
Aniruddh Agarwal
@anrddh
Sep 08 2015 09:40
I made an infinite loop
That stopped when the number reached was divisible by all the provided numbers in the array
Rory Smith
@alanbuchanan
Sep 08 2015 09:41
that was my original intention. but someone pointed out it was ridiculously inefficient
(i don't like how this is only 2/5 difficulty, it's 10x more complex than the other 2/5s :)
Aniruddh Agarwal
@anrddh
Sep 08 2015 09:44
Well my code worked for numbers from 1 through 20 within a minute, so I guess it is efficient enough for the purpose of the bonfire :P
Rory Smith
@alanbuchanan
Sep 08 2015 09:45
so what would you do if you had to do numbers 1 through 10,000?
Aniruddh Agarwal
@anrddh
Sep 08 2015 09:46
I'd call up NASA and use their supercomputer
Rory Smith
@alanbuchanan
Sep 08 2015 09:46
@awesomeaniruddh :laughing:
Mbos95
@Mbos95
Sep 08 2015 09:52
This message was deleted
This message was deleted

grocery shopping

  • tomatoes
  • playdough
  • Squid
awesome
This message was deleted
Mbos95
@Mbos95
Sep 08 2015 09:57
ballooooons
Rory Smith
@alanbuchanan
Sep 08 2015 09:58
@awesomeaniruddh do you know what method i can use that returns true or false based on the values of every element of the array? eg if 1, 2, 3, 4 AND 5 all fit into 60, return true
Aniruddh Agarwal
@anrddh
Sep 08 2015 09:58
For the bf?
Rory Smith
@alanbuchanan
Sep 08 2015 09:58
yeah
Aniruddh Agarwal
@anrddh
Sep 08 2015 09:59
Loop through the provided array for every number
Rory Smith
@alanbuchanan
Sep 08 2015 09:59
and in general...
Aniruddh Agarwal
@anrddh
Sep 08 2015 09:59
current number % arr[i] === 0
if true then, continue
if false, then break
Rajendra kadam
@raju249
Sep 08 2015 09:59
I am having problem verifying my work on npm challenge "Publish Again"
Please help
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:00
if i == arr[-1], then return that number, exiting the outer infinite loop
This message was deleted
Mbos95
@Mbos95
Sep 08 2015 10:07
Sorry guys but I need to say I am proud of myself
my first bonfire which I totally got and did by myself :D
Normally I spend hours tinkering with it and being all confused!
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:07
bonfire?
CamperBot
@camperbot
Sep 08 2015 10:07
we're talking about bonfire :fire: Bonfire: Smallest Common Multiple
Mbos95
@Mbos95
Sep 08 2015 10:07
Just wanted to announce that!
Bonfire: Confirm the Ending
CamperBot
@camperbot
Sep 08 2015 10:08

:fire:Bonfire: Confirm the Ending :link:

function end(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  return str;
}

end('Bastian', 'n');

Check if a string (first argument) ends with the given target string (second argument).

more info:  bf details | bf links | hint

Mbos95
@Mbos95
Sep 08 2015 10:08
it's an easy one i think, but hey! I did ittt :D
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:08
:thumbsup:
You have a long journey ahead of you. May you prevail over it!
Mbos95
@Mbos95
Sep 08 2015 10:09
function end(str, target) {
  var totalstring = (str.length);
  var beginstring = (str.length-target.length);
  var equal = str.substr(beginstring,totalstring) ;
  if(equal === target){
    return true;
  }else{
    return false;
  }
}

end('Bastian', 'n');
How about my coding? any tips?
or does it look neat?
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:10
function end(str, target) {
  var totalstring = (str.length);
  var beginstring = (str.length-target.length);
  var equal = str.substr(beginstring,totalstring) ;

if(equal === target) return true;
  return false;
}

end('Bastian', 'n');
that removed 3 lines form your code :P
Rory Smith
@alanbuchanan
Sep 08 2015 10:11
@awesomeaniruddh finally!!!
function smallestCommons(arr){ 
    var small = Math.min(arr[0], arr[1]),
        big = Math.max(arr[0], arr[1]);

    var newArr = [];
    for(var i = small; i <= big; i++){
        newArr.push(i);
    }

    var j = 50,
        result = 0,
        done = false;

    while(done === false){
        for(var i = 0; i < newArr.length; i++){
            if(j % newArr[i] === 0){
                continue;
            } else {
                j++;
                i = 0;
            }
        }
        done = true;
    }

    return j;
}
through brute force
Mbos95
@Mbos95
Sep 08 2015 10:11
oh yea, seen that before. for me it is weird how you just massacre the if statement
Thanks :D
CamperBot
@camperbot
Sep 08 2015 10:11
if you want to thank someone, put an @ before their name!
Mbos95
@Mbos95
Sep 08 2015 10:11
thanks @awesomeaniruddh
CamperBot
@camperbot
Sep 08 2015 10:11
mbos95 sends brownie points to @awesomeaniruddh :sparkles: :thumbsup: :sparkles:
:star: 369 | @awesomeaniruddh | http://www.freecodecamp.com/awesomeaniruddh
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:11
If you enjoyed this, you should definitely check out Project euler @alanbuchanan
Rory Smith
@alanbuchanan
Sep 08 2015 10:11
thanks for your advice @awesomeaniruddh you made me think about it the brute force way
CamperBot
@camperbot
Sep 08 2015 10:11
alanbuchanan sends brownie points to @awesomeaniruddh :sparkles: :thumbsup: :sparkles:
:star: 370 | @awesomeaniruddh | http://www.freecodecamp.com/awesomeaniruddh
Rory Smith
@alanbuchanan
Sep 08 2015 10:11
@awesomeaniruddh i HATED it
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:11
haha
Rory Smith
@alanbuchanan
Sep 08 2015 10:11
but i have done some eulers, it might surprise you
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:12
how many did you finish?
Rory Smith
@alanbuchanan
Sep 08 2015 10:12
4 i think
maybe 5
Vikrant Negi
@vikrantnegi
Sep 08 2015 10:12
help needed in Bonfire: Return Largest Numbers in Arrays
function largestOfFour(arr) {

  var largest=0;
  for(i=0; i<=largest; i++){
    if(array[i]>largest){
      var largest=array[i];
    }
  }
  // You can do this!
  return largest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
CamperBot
@camperbot
Sep 08 2015 10:12
no wiki entry for: needed in bonfire return largest numbers in arraysjavascriptfunction largestoffourarr var largest0 fori0 ilargest i ifarrayilargest var largestarrayi you can do this return largestlargestoffour4 5 1 3 13 27 18 26 32 35 37 39 1000 1001 857 1
:pencil: click here to create one now!after creating your page type update to reload it here
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:12
They make you think ;)
Rory Smith
@alanbuchanan
Sep 08 2015 10:12
but my solutions were outstandingly bad
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:12
I did the first 20
then I got bored
Rajendra kadam
@raju249
Sep 08 2015 10:13
npm ERR! Linux 3.14.13-c9
npm ERR! argv "node" "/home/ubuntu/.nvm/v0.10.35/bin/npm" "publish"
npm ERR! node v0.10.35
npm ERR! npm  v2.14.1
npm ERR! code ENEEDAUTH

npm ERR! need auth auth required for publishing
npm ERR! need auth You need to authorize this machine using `npm adduser`

npm ERR! Please include the following file with any support request:
npm ERR!     /home/ubuntu/workspace/packages/npm-debug.log
I get this error on publishing a node package again on cloud9
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:13
your if statement is invalid @vikrantnegi007
@raju249 You need to run npm adduser
Rajendra kadam
@raju249
Sep 08 2015 10:14
i did
@awesomeaniruddh
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:14
@vikrantnegi007 You're comparing an integer and an array
Rolands Jegorovs
@Rolandisimo
Sep 08 2015 10:14
Hey, can someone give me a tip about switch statements? How can I write operators in the case value? It's just my switch is defaulting cause no values are accepted.
Mbos95
@Mbos95
Sep 08 2015 10:15
function largestOfFour(arr) {

  var largest=0;
  for(i=0; i < arr.length; i++){
   var currArr = arr[i];
    for(j = 0; j < currArr.length; j++){  \\ cycles through subarrays

}
}

  return largest;
}
Rory Smith
@alanbuchanan
Sep 08 2015 10:15
@Rolandisimo this should help
Mbos95
@Mbos95
Sep 08 2015 10:16
```
function largestOfFour(arr) {

  var largest=0;
  for(i=0; i < arr.length; i++){
   var currArr = arr[i];
    for(j = 0; j < currArr.length; j++){  \\ cycles through subarrays

}
}

  return largest;
}
}
```
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:16
Yep ^
Though your indentation is off :P
Rory Smith
@alanbuchanan
Sep 08 2015 10:16
@Rolandisimo if it's not getting the intended value try debugging with dev tools
Mbos95
@Mbos95
Sep 08 2015 10:16
Eh! close enough :D
Rajendra kadam
@raju249
Sep 08 2015 10:17
@awesomeaniruddh
 Linux 3.14.13-c9
npm ERR! argv "node" "/home/ubuntu/.nvm/v0.10.35/bin/npm" "adduser"
npm ERR! node v0.10.35
npm ERR! npm  v2.14.1
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! syscall connect

npm ERR! Error: connect ECONNREFUSED
npm ERR!     at errnoException (net.js:905:11)
npm ERR!     at Object.afterConnect [as oncomplete] (net.js:896:19)
npm ERR!  { [Error: connect ECONNREFUSED]
npm ERR!   code: 'ECONNREFUSED',
npm ERR!   errno: 'ECONNREFUSED',
npm ERR!   syscall: 'connect' }
npm ERR! 
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly.  See: 'npm help config'

npm ERR! Please include the following file with any support request:
npm ERR!     /home/ubuntu/workspace/packages/npm-debug.log
I get this error on running npm adduser
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:17
no idea, never published a package on NPM before
Rajendra kadam
@raju249
Sep 08 2015 10:18
OKai no problem
Rolands Jegorovs
@Rolandisimo
Sep 08 2015 10:18
@alanbuchanan I understand how they work. I have an another working switch statement. But I want to know whether or not I can write operators in the values.
Mbos95
@Mbos95
Sep 08 2015 10:18
why is it all ERR!
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:18
Might be a C9 thing
Rory Smith
@alanbuchanan
Sep 08 2015 10:18
@raju249 someone on stackoverflow should be able to help with that
Rajendra kadam
@raju249
Sep 08 2015 10:18
Can anyone help me please
Rolands Jegorovs
@Rolandisimo
Sep 08 2015 10:18
@alanbuchanan Here's my code
switch(windDeg) {
          case '= 0':
              windDegEl.innerHTML = "North";
              break;
          case '> 0':
              windDegEl.innerHTML = "N/NE";
              break;
          case '= 45':
              windDegEl.innerHTML = "Northeast";
              break;
          case '> 45':
              windDegEl.innerHTML = "NE/E";
              break;
          case '= 90':
              windDegEl.innerHTML = "East";
              break;
          case '> 90':
              windDegEl.innerHTML = "E/SE";
              break;
          case '= 135':
              windDegEl.innerHTML = "Southeast";
              break;
          case '> 135':
              windDegEl.innerHTML = "SE/S";
              break;
          case '= 180':
              windDegEl.innerHTML = "South";
              break;
           case '> 180':
              windDegEl.innerHTML = "S/SW";
              break;
          case '= 225':
              windDegEl.innerHTML = "Southwest";
              break;
          case '> 225':
              windDegEl.innerHTML = "SW/W";
              break;
          case '= 270':
              windDegEl.innerHTML = "West";
              break;
          case '> 270':
              windDegEl.innerHTML = "W/NW";
              break;
          case '= 315':
              windDegEl.innerHTML = "Northwest";
              break;
          case '> 315':
              windDegEl.innerHTML = "NW/N";
              break;
          case '= 360':
              windDegEl.innerHTML = "North";
              break;
          default:
              windDegEl.innerHTML = "Windy";
        }
Mbos95
@Mbos95
Sep 08 2015 10:18
Oh, ignore mt by the way! I am an noob and was wondering why there was ERR!
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:18
I would just Google for a library that does that for me :P
@Rolandisimo
Rory Smith
@alanbuchanan
Sep 08 2015 10:19
@Rolandisimo have you typed windDegEl.innerHTML into the console to see what it's value is? it might not be exactly what you expect
Rolands Jegorovs
@Rolandisimo
Sep 08 2015 10:19
@awesomeaniruddh Well, It's good to know though. :)
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:19
Try console.logging
for debugging
Rory Smith
@alanbuchanan
Sep 08 2015 10:20

for example you may possibly need

document.getElementById(windDegEl).innerHTML

or

$('#windDegEl').html()
Rolands Jegorovs
@Rolandisimo
Sep 08 2015 10:22
@alanbuchanan I have set all the elements I need before.
windDegEl = document.getElementById("windDeg"),
@alanbuchanan It returns the default value of the switch
@alanbuchanan Meaning that the values can not be written this way, I assume
Rory Smith
@alanbuchanan
Sep 08 2015 10:23
with the operator as well?
is it literally > n or just n
Read the first answer
Rory Smith
@alanbuchanan
Sep 08 2015 10:24
@awesomeaniruddh in fact that's exactly what i used for mine
@Rolandisimo i went down a similar route
var c = parseInt(weather.code);
            switch(true) {
                // Rainy
                case (c >= 0 && c <= 12 || c === 35 || c >= 37 && c <= 40 || c >= 45 && c <= 47):
                    changeBgImg(rainyImg);
                    break;
                // Sunny
                case (c === 19 || c === 21 || c === 22 || c === 32 || c === 34 || c === 36):
                    changeBgImg(sunnyImg);
                    break;
//etc.....
Rajendra kadam
@raju249
Sep 08 2015 10:25
When i run how-to-npm
I get the following error
    throw err;
          ^
Error: Cannot find module '/home/ubuntu/.config/how-to-npm/registry/serverjs/body.json'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.exports.verify (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/how-to-npm/problems/11-dist-tag.js:42:14)
    at Shop.verify (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/how-to-npm/node_modules/adventure/index.js:157:15)
    at Shop.execute (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/how-to-npm/node_modules/adventure/index.js:76:14)
    at Shop.shop.execute (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/how-to-npm/index.js:37:45)
    at Object.<anonymous> (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/how-to-npm/index.js:86:8)
    at Module._compile (module.js:456:26)
Rolands Jegorovs
@Rolandisimo
Sep 08 2015 10:25
@awesomeaniruddh Hey, thanks for that. :)
CamperBot
@camperbot
Sep 08 2015 10:25
rolandisimo sends brownie points to @awesomeaniruddh :sparkles: :thumbsup: :sparkles:
:star: 371 | @awesomeaniruddh | http://www.freecodecamp.com/awesomeaniruddh
Rolands Jegorovs
@Rolandisimo
Sep 08 2015 10:26
@alanbuchanan Yeah, it seems I need to have the expression as "true"
@alanbuchanan Thanks :)
CamperBot
@camperbot
Sep 08 2015 10:26
rolandisimo sends brownie points to @alanbuchanan :sparkles: :thumbsup: :sparkles:
:star: 263 | @alanbuchanan | http://www.freecodecamp.com/alanbuchanan
Rory Smith
@alanbuchanan
Sep 08 2015 10:26
@Rolandisimo using ranges with switches seem to be a bit of a pain :)
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:27
#JustUseIF :)
Rolands Jegorovs
@Rolandisimo
Sep 08 2015 10:27
@alanbuchanan It is.
Rory Smith
@alanbuchanan
Sep 08 2015 10:27
it's like they didn't even consider it when they designed the language (in 10 days)
Rolands Jegorovs
@Rolandisimo
Sep 08 2015 10:27
Well, switch seems more readable for masses of data
But that's just me :)
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:27
Only marginally
But it's subject :)
Rolands Jegorovs
@Rolandisimo
Sep 08 2015 10:28
Sure is. Wonder though is anyone of them faster. :shipit:
Rajendra kadam
@raju249
Sep 08 2015 10:29
Please sombody help
Rolands Jegorovs
@Rolandisimo
Sep 08 2015 10:30
@raju249 Sorry, don't know the subject of node. Good luck though.
Rory Smith
@alanbuchanan
Sep 08 2015 10:30
@raju249 try stackoverflow, there's bound to be someone there that has a solution
Aniruddh Agarwal
@anrddh
Sep 08 2015 10:31
Also, node and npm on C9 are outdated
try updating them
Rolands Jegorovs
@Rolandisimo
Sep 08 2015 10:33
I just understood that I need to reverse the switch statement. :D Because if the windDeg is e.g. 300, then the statement (windDeg > 45) will be true
The pain
Rory Smith
@alanbuchanan
Sep 08 2015 10:35
@Rolandisimo if only javascript was that intuitive :)
Rolands Jegorovs
@Rolandisimo
Sep 08 2015 10:36
@alanbuchanan With experience comes great responsibility :D
dormouss
@dormouss
Sep 08 2015 10:40

I'm working on the Where Art Thou 'onfire and in my quest to solve that, I encountered the following code on the internet, and I don't understand why it works.

  var filters = [{"user":"abc"},{"application":"xyz"}];
console.log(Object.keys(filters[0])[0]); // prints user
var term = (Object.keys(filters[0])[0]);
console.log(filters[0][term]);

My Question: where does this 'filters()' method come from? It's not the filter() method, it's filters with an s. When I search for it, all I find is references to filter().

Oh, dangit. Filters is the variable that's being called.
Rory Smith
@alanbuchanan
Sep 08 2015 10:42
@dormouss you set filters yourself
dormouss
@dormouss
Sep 08 2015 10:43
I think I have answered my own question.
Thanks @alanbuchanan .
CamperBot
@camperbot
Sep 08 2015 10:43
dormouss sends brownie points to @alanbuchanan :sparkles: :thumbsup: :sparkles:
:star: 264 | @alanbuchanan | http://www.freecodecamp.com/alanbuchanan
Rory Smith
@alanbuchanan
Sep 08 2015 10:43
@dormouss :)
Fahad Uddin
@FahadUddin92
Sep 08 2015 10:52
Hello folks. I just did exercise 37 but the submit button is not working anymore.
Please have a look:
http://imgur.com/5UMwhCo
Sasa
@tanasic
Sep 08 2015 10:55
@enggfahd I know it might sound dumb, but have you tried closing that and resubmitting or refreshing browser :/
Fahad Uddin
@FahadUddin92
Sep 08 2015 10:57
@tanasic: Just tried to go back and redo the exercise and it worked. Thanks.
CamperBot
@camperbot
Sep 08 2015 10:57
if you want to thank someone, put an @ before their name!
Elizabeth Hatleli
@TheHighPriestess
Sep 08 2015 11:14

I'm not sure how to construct an If statement using a regular expression. For example, how do I write this:

If the variable "before" contains a capital letter [A-Z]+ THEN do something....

Rory Smith
@alanbuchanan
Sep 08 2015 11:17
you could use test
it'll give you true or false
Sasa
@tanasic
Sep 08 2015 11:18
guys.. who can help me with Waypoint: Bring your JavaScript Slot Machine to Life
everything is working as it should but it says
You should have used the the selector given in the description to select each slot and assign it the value of slotOne, slotTwo and slotThree respectively
$($('.slot')[0]).html(slotOne);
    $($('.slot')[1]).html(slotTwo);
    $($('.slot')[2]).html(slotThree);
DTing
@dting
Sep 08 2015 11:20
@tanasic use double quotes
the challenge uses string matching to check your answer.
Sasa
@tanasic
Sep 08 2015 11:20
@dting same result, but now it says correct.. weird.. thank you
CamperBot
@camperbot
Sep 08 2015 11:20
tanasic sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1050 | @dting | http://www.freecodecamp.com/dting
marzelin
@marzelin
Sep 08 2015 11:21
This message was deleted
Elizabeth Hatleli
@TheHighPriestess
Sep 08 2015 11:28
@alanbuchanan thank you...I will check that out
CamperBot
@camperbot
Sep 08 2015 11:28
thehighpriestess sends brownie points to @alanbuchanan :sparkles: :thumbsup: :sparkles:
:star: 267 | @alanbuchanan | http://www.freecodecamp.com/alanbuchanan
John Carl James Nebab
@navip0t
Sep 08 2015 11:33
function mutation(arr) {
  var str1 = arr[0].split('');
  var str2 = arr[1].split('');
  for(var i=0;i < str1.length; i++) {
    for(var j=0;j < str2.length; j++) {
      var elem1 = str1[i];
      var elem2 = str2[j];
      var idx1 = arr[0].indexOf(elem1);
      var idx2 = arr[1].indexOf(elem2);
      if(idx1 == idx2) {
        return true;
      } else {
        return false;
      }
    }
  }
}

mutation(['hello', 'hey']);
can anyone help me?
```
marzelin
@marzelin
Sep 08 2015 11:33
find mutation
CamperBot
@camperbot
Sep 08 2015 11:33

find mutation

:zero: bonfire mutations

John Carl James Nebab
@navip0t
Sep 08 2015 11:34
thanks @camperbot
CamperBot
@camperbot
Sep 08 2015 11:34
navip0t sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star: 189 | @camperbot | http://www.freecodecamp.com/camperbot
Mbos95
@Mbos95
Sep 08 2015 11:36
Hey guys, anyone wants to answer an question I have? It is regarding bonfire chunky monkey
function chunk(arr, size) {
   var string = arr.join('');
  var num = size;
  var begin = 0;
  var end = num;
  var endarray= [];
  for(var i = 0;i < string.length;i++){
    var array = string.substring(begin,end)

    endarray.push([array])

    end+size;
    begin+size;
  }
  return endarray;
}

chunk(['a', 'b', 'c', 'd'], 2);
I have this. It should update the var begin and the var num everytime it iterates,right? How to properly let it do that ?
nevermind. got that part now xD
sorry to disturb y'all!
marzelin
@marzelin
Sep 08 2015 11:38
wiki chunky monkey
CamperBot
@camperbot
Sep 08 2015 11:38

:point_right: bonfire chunky monkey [wiki]

Our goal for this bonfire is to split arr (first argument) into smaller chunks of arrays with the length provided by size (second argument). There are 4 green checks (objectives) our code needs to pass in order to complete this bonfire:

  1. (['a', 'b', 'c', 'd'], 2) is expected to be [['a', 'b'], ['c', 'd']]
  2. ([0, 1, 2, 3, 4, 5], 3) is expected to be [[0, 1, 2], [3, 4, 5]]
  3. ([0, 1, 2, 3, 4, 5], 2) is expected to be [[0, 1], [2, 3], [4, 5]]
  4. ([0, 1, 2, 3, 4, 5], 4) is expected to be [[0, 1, 2, 3], [4, 5]]

Click More information under the bonfire title and read the helpful links if you haven't yet.

How to approach the bonfire

The helpful links suggest to use Array.push() so let's start by first creating a new array to store the smaller arrays we will soon have like this:

var newArray = [];

Next we'll need a for loop to loop through arr then finally we need a method to do the actual splitting and we can use Array.slice() to do that. The key to this bonfire is understanding how a for loop, size, Array.slice() and Array.push() all work together.

How does a for loop and Array.slice() work

For Loop

:pencil: read more about bonfire chunky monkey on the FCC Wiki

Rabin Shrestha
@jyapujuju
Sep 08 2015 11:41
function where(arr, num) {
  // Find my place in this sorted array.
  var sum=[];
  sum=arr.concat(num);
  sum.sort();
  return sum;
}

where([40, 60], 50);
whats wrong here?
assert.strictEqual(where([10, 20, 30, 40, 50], 35), 3, '35 should be placed at index 3');
35 should be placed at index 3: expected [ 10, 20, 30, 35, 40, 50 ] to equal 3
DTing
@dting
Sep 08 2015 11:42
@jyapujuju that returns the array
sum
marzelin
@marzelin
Sep 08 2015 11:42
check how sort() method works @jyapujuju you'll be suprised
DTing
@dting
Sep 08 2015 11:42
you need to return the index where the num is inserted
Rabin Shrestha
@jyapujuju
Sep 08 2015 11:44
oh sorry
Conor Sinclair
@conordot
Sep 08 2015 11:45
Hey all, I'm doing Zipline: Show the Local Weather and for some reason the value its retrieving for the weather is not accurate at all. Do I need to parse it or anything? It should be 12 but its showing 29 :S
(Sorry value from JSON)
John Carl James Nebab
@navip0t
Sep 08 2015 11:45
Thanks @sxmxc @Rafase282
CamperBot
@camperbot
Sep 08 2015 11:45
navip0t sends brownie points to @sxmxc and @rafase282 :sparkles: :thumbsup: :sparkles:
:star: 414 | @rafase282 | http://www.freecodecamp.com/rafase282
:star: 177 | @sxmxc | http://www.freecodecamp.com/sxmxc
Sasa
@tanasic
Sep 08 2015 11:46
guys anyone good with JavaScript here ?
I am just wondering how can I do the first basic leeson somewhere outside of freecodecamp like codepen or my terminal in ubuntu
Rabin Shrestha
@jyapujuju
Sep 08 2015 11:46
function where(arr, num) {
  // Find my place in this sorted array.
  var sum=[];
  sum=arr.concat(num);
  sum.sort();
  for(var i=0;i<sum.length;i++){
    if(sum[i]===num){
      return i;
    }
  }
}

where([40, 60], 50);
DTing
@dting
Sep 08 2015 11:46
@conordot i'm guessing you are doing the ajax request before your long and lat are set
Rabin Shrestha
@jyapujuju
Sep 08 2015 11:46
assert.strictEqual(where([5, 3, 20, 3], 3), 0, '3 should be placed at index 0');
3 should be placed at index 0: expected 1 to equal 0
Sasa
@tanasic
Sep 08 2015 11:46
i wanna test this outside of codecamp and get the TRUE result
function welcomeToBooleans() {

// don't change code above here

  return true;

// Only change code above this line.
}

welcomeToBooleans();
is that possible ?
Carl Huxley
@carlhuxley
Sep 08 2015 11:46
Hi, can anyone see what I've accidentally deleted to stop the style being applied to the round-image class on my portrait photo? http://codepen.io/CarlHux/pen/GJbwPP How do I get it to display round again instead of square? Anybody else find it difficult debugging using the editor on code pen?
DTing
@dting
Sep 08 2015 11:47

@jyapujuju from that mdn page

compareFunction
Optional. Specifies a function that defines the sort order. If omitted, the array is sorted according to each character's Unicode code point value, according to the string conversion of each element.

you need to provide a compare function for the sort call
Mbos95
@Mbos95
Sep 08 2015 11:49
function chunk(arr, size) {
   var string = arr.join('');
  var times =(string.length/size)
  var num = size;
  var begin = 0;
  var end = num;
  var endarray= [];
  for(var i = 0;i < times;i++){
    var string2 = string.substring(begin,end)
    var array = string2.split('')
    endarray.push(array)


    end = end+size;
    begin = begin+size;
  }
  return endarray;
}

chunk(['a', 'b', 'c', 'd'], 2);
Why doesn't that pass?
If it has to do with the output of the numbers being "" instead of '' .. how can I possibly change that ?
Rory Smith
@alanbuchanan
Sep 08 2015 11:49
@carlhuxley try img-circle instead of round-image in your html
Elizabeth Hatleli
@TheHighPriestess
Sep 08 2015 11:52
Is this correct: if ([A-Z]+.test(str)) ???
if I want to test for that regex?
DTing
@dting
Sep 08 2015 11:53
@carlhuxley you have an extra curly bracket above your .round-image declaration
in your css
remove that and your css styles below that will come back
marzelin
@marzelin
Sep 08 2015 11:54
@TheHighPriestess enclose regexp with / /
Elizabeth Hatleli
@TheHighPriestess
Sep 08 2015 11:54
@marzelin like this? if (/[A-Z]+/.test(str))
marzelin
@marzelin
Sep 08 2015 11:54
@TheHighPriestess should work
DTing
@dting
Sep 08 2015 11:55
also your div above your image in in your html is missing a space between div and class
Elizabeth Hatleli
@TheHighPriestess
Sep 08 2015 11:55
@marzelin ok..thank you
CamperBot
@camperbot
Sep 08 2015 11:55
thehighpriestess sends brownie points to @marzelin :sparkles: :thumbsup: :sparkles:
:star: 131 | @marzelin | http://www.freecodecamp.com/marzelin
Rory Smith
@alanbuchanan
Sep 08 2015 11:59
@TheHighPriestess you can also use a RegExp if you want to include a variable in your regex test, or just for better readability:
function checkForCaps(str){
    var capsRegex = new RegExp("[A-Z]+");
    return capsRegex.test(str);
}

checkForCaps('Has a capital'); //true
checkForCaps('doesn\'t have a capital'); // false
Mbos95
@Mbos95
Sep 08 2015 12:00
How can I have an IF statement check if an variable is an number or string?
if(){

}
marzelin
@marzelin
Sep 08 2015 12:00
@Mbos95 typeof
Rory Smith
@alanbuchanan
Sep 08 2015 12:00
@Mbos95
if(typeof something === 'number'){}
Carl Huxley
@carlhuxley
Sep 08 2015 12:01
Thanks @dting I couldn't see it for looking!
CamperBot
@camperbot
Sep 08 2015 12:01
carlhuxley sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1052 | @dting | http://www.freecodecamp.com/dting
Elizabeth Hatleli
@TheHighPriestess
Sep 08 2015 12:01
@alanbuchanan ah...ok...thanks
CamperBot
@camperbot
Sep 08 2015 12:01
thehighpriestess sends brownie points to @alanbuchanan :sparkles: :thumbsup: :sparkles:
:warning: thehighpriestess already gave alanbuchanan points
Mbos95
@Mbos95
Sep 08 2015 12:02
Thanks @marzelin @alanbuchanan !
CamperBot
@camperbot
Sep 08 2015 12:02
mbos95 sends brownie points to @marzelin and @alanbuchanan :sparkles: :thumbsup: :sparkles:
:star: 132 | @marzelin | http://www.freecodecamp.com/marzelin
:star: 268 | @alanbuchanan | http://www.freecodecamp.com/alanbuchanan
DTing
@dting
Sep 08 2015 12:02
@TheHighPriestess @alanbuchanan dont use the constructor for RegExp unless the regex is changing. use the literal notation.
if you put that function in a loop. every loop that runs will compile a new regexp
Rory Smith
@alanbuchanan
Sep 08 2015 12:04
@dting can you explain what is the constructor in this case? and 'the regex is changing'?
DTing
@dting
Sep 08 2015 12:05
whenever you use the word new you are creating a new object.
the regex is always going to be /[^A-Z]/ so you should use the literal notation
you would use the RegExp constructor if you needed to compile a regexp at runtime
Rory Smith
@alanbuchanan
Sep 08 2015 12:06
@dting i see what you mean
Aniruddh Agarwal
@anrddh
Sep 08 2015 12:06
More memory and more processing time
DTing
@dting
Sep 08 2015 12:06
for example:
function checkMyExp(exp, case) {
  return new RegExp(exp).test(case);
}
Rory Smith
@alanbuchanan
Sep 08 2015 12:07
i assume you meant test? or i'm missing something else
DTing
@dting
Sep 08 2015 12:07
ya typo
Mbos95
@Mbos95
Sep 08 2015 12:08
function chunk(arr, size) {
   var string = arr.join('');
  var times =(string.length/size)
  var begin = 0;
  var end = size;
  var endarray= [];
  var number = '';
  var string = "";
  for(var i = 0;i < times;i++){
    var string2 = string.substring(begin,end)

    end = end+size;
    begin = begin+size;


    if(typeof string2 === 'string'){
       var array = string2.split('')
        endarray.push(array)

    }else if(typeof string2 === 'number'){
      var array = string2.split('')
      endarray.push(array)

    }
  }
  return endarray;
}

chunk(['a', 'b', 'c', 'd'], 2);
Why doesn't this work ?
Aniruddh Agarwal
@anrddh
Sep 08 2015 12:09
That's one scary piece of code :P
Rory Smith
@alanbuchanan
Sep 08 2015 12:09
bearing this in mind from now on, just for readability:
function checkForCaps(str){
    var capsRegex = /[A-Z]+/;
    return capsRegex.test(str);
}
Aniruddh Agarwal
@anrddh
Sep 08 2015 12:09
which bf @Mbos95
DTing
@dting
Sep 08 2015 12:09
an alternative to using test is to use String.search
'hello'.search(/ell/) > -1
true
'hello'.search(/a/) > -1
false
Mbos95
@Mbos95
Sep 08 2015 12:09
bonfire chunky monkey
CamperBot
@camperbot
Sep 08 2015 12:09

:fire:Bonfire: Chunky Monkey :link:

function chunk(arr, size) {
  // Break it up.
  return arr;
}

chunk(['a', 'b', 'c', 'd'], 2);

Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a multidimensional array.

more info:  bf details | bf links | hint

Mbos95
@Mbos95
Sep 08 2015 12:10
Oh yea, I can look at the hints and usch aswell
Rory Smith
@alanbuchanan
Sep 08 2015 12:10
@dting search is for when you want the order of vars reversed right?
Aniruddh Agarwal
@anrddh
Sep 08 2015 12:11
  1. The second argument is not always a factor of the length of the first argument
You will need to account for that
Mbos95
@Mbos95
Sep 08 2015 12:11
I need it to recognize is string2 is a number or string and either split it with '' (number) and "" for a string
I know it won't be. :)
Aniruddh Agarwal
@anrddh
Sep 08 2015 12:11
string2 will always be a string
'1' is a string
'10239'
is also a string
Mbos95
@Mbos95
Sep 08 2015 12:12
but how can I then recognize it ? I need to know what the content of the string will be
Rory Smith
@alanbuchanan
Sep 08 2015 12:12
@dting ahhh it returns the index rather than a boolean
Aniruddh Agarwal
@anrddh
Sep 08 2015 12:13
Why so?
Rory Smith
@alanbuchanan
Sep 08 2015 12:13
@dting thanks for pointing that out
CamperBot
@camperbot
Sep 08 2015 12:13
alanbuchanan sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1053 | @dting | http://www.freecodecamp.com/dting
Mbos95
@Mbos95
Sep 08 2015 12:13
function chunk(arr, size) {
   var string = arr.join('');
  var times =(string.length/size)
  var begin = 0;
  var end = size;
  var endarray= [];

  for(var i = 0;i < times;i++){
    var string2 = string.substring(begin,end)

      var array = string2.split('')
      endarray.push(array)

    end = end+size;
    begin = begin+size;


  }
  return endarray;
}

chunk(['a', 'b', 'c', 'd'], 2);
@awesomeaniruddh I had it like this. It should be able to pass. but I think it doesn't because around the numbers in the endarray is "" instead of ''
Aniruddh Agarwal
@anrddh
Sep 08 2015 12:14
that doesn't matter
Mbos95
@Mbos95
Sep 08 2015 12:15
then I should be able to pass
bf hint
CamperBot
@camperbot
Sep 08 2015 12:15
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Aniruddh Agarwal
@anrddh
Sep 08 2015 12:15
okay yeah
my bad :P
You need to remove the quotes from the numbers
Blauelf
@Blauelf
Sep 08 2015 12:16
Maybe it is not the best idea to join the array to a string. Would you be able to work on chunk(['a1', 'b', 'c', 'd'], 2);? An element does not have to be single character only, even if those test cases are all that way.
Aniruddh Agarwal
@anrddh
Sep 08 2015 12:16
You can use regex to check for numbers
DTing
@dting
Sep 08 2015 12:16
dont join the array
just use arr.length
Mbos95
@Mbos95
Sep 08 2015 12:17
@awesomeaniruddh Even if i were to check for numbers using regex, I doubt i'll be able to get the ""changed into '' in an efficient way
Yea but I couldn't find a way to effectively use indexes of the array for this. arrays are troubling to me! so I thought I would just make a string of it and then do all the manipulation and then make an array of it again
Aniruddh Agarwal
@anrddh
Sep 08 2015 12:18
function chunk(arr, size) {
  var arrLength = arr.length;
  var times =(arrLength/size)
  var begin = 0;
  var end = size;
  var endarray= [];

  for(var i = 0;i < times;i++){
    var string2 = arr.slice(begin,end)

    endarray.push(string2)

     end = end+size;
     begin = begin+size;
  }


  return endarray;
}

chunk([0, 1, 2, 3, 4, 5], 3);
I made a few modifications
Manish Gupta
@mformanish
Sep 08 2015 12:21
@awesomeaniruddh Fixed it well, for @Mbos95
Mbos95
@Mbos95
Sep 08 2015 12:23
Oh! that works (sorry computer crashed from the intensity , i think)
Well, okay! lesson learned again xD trying to avoid the arrays will catch up with me in the end. :D
Thanks @dting @awesomeaniruddh @Blauelf
CamperBot
@camperbot
Sep 08 2015 12:23
mbos95 sends brownie points to @dting and @awesomeaniruddh and @blauelf :sparkles: :thumbsup: :sparkles:
:star: 263 | @blauelf | http://www.freecodecamp.com/blauelf
:star: 373 | @awesomeaniruddh | http://www.freecodecamp.com/awesomeaniruddh
:star: 1054 | @dting | http://www.freecodecamp.com/dting
Blauelf
@Blauelf
Sep 08 2015 12:23
My somewhat arbitrary testcase chunk([1,'false',[],{'foo':'bar'},undefined,null],4) works for your algorithm :)
Mbos95
@Mbos95
Sep 08 2015 12:23
o.0
wauw not sure what that is..
Aniruddh Agarwal
@anrddh
Sep 08 2015 12:24
:)
DorSarel
@DorSarel
Sep 08 2015 12:24
function bouncer(arr) {
  // Don't show a false ID to this bouncer.

  arr.filter(function(value){
    for(var i = 0; i < arr.length; i++){
      value = new Boolean(arr[i]);
      if(value === true){
        return value;
      }
    }
  });
  return arr;
}

bouncer([7, 'ate', '', false, 9]);
what is wrong with my code?
Aniruddh Agarwal
@anrddh
Sep 08 2015 12:25
function bouncer(arr) {
  // Don't show a false ID to this bouncer.

  arr = arr.filter(function(value){
    return value;
  });
  return arr;
}

bouncer([7, 'ate', '', false, 9]);
That works
DTing
@dting
Sep 08 2015 12:25
arr.filter doesnt change the arr
you would have to return the result of that filter call directly or assign it to something
Aniruddh Agarwal
@anrddh
Sep 08 2015 12:26
Very few people seem to be aware that return evaluates the expression next to it
Blauelf
@Blauelf
Sep 08 2015 12:26
@Mbos95 1 is a number. 'false' is a string. [] is an empty array. {'foo':'bar'} is a simple object. undefined is very special (and the only thing of type undefined!) and null is null. So there are many different types, and all those would make problems if you went the .join('') way.
DorSarel
@DorSarel
Sep 08 2015 12:27
@dting i assigned it to another array that i made... but it givining me back an empty array
DTing
@dting
Sep 08 2015 12:28
@DorSarel
new Boolean(true) === true;
false
you dont want to use the Boolean object contructor
you want to use the Boolean function
Boolean(true) === true;
true
you also dont want to iterate over your array inside your filter callback function
DorSarel
@DorSarel
Sep 08 2015 12:30
@dting Ok - now i understand i read about it in the docs but didnt quite understand it
@dting why not?
DTing
@dting
Sep 08 2015 12:30
the callback function that you give the filter function is called once for each element in the array with the element as the first argument
Aniruddh Agarwal
@anrddh
Sep 08 2015 12:30
cuz filter is already iterating over your array
Blauelf
@Blauelf
Sep 08 2015 12:30
The filter function iterates for you, giving value, index and array as the three input parameters to your inner function. You don't have to name them all, if you don't need them.
Aniruddh Agarwal
@anrddh
Sep 08 2015 12:30
you are essentially iterating over every value in your array for every value in your array
DTing
@dting
Sep 08 2015 12:32
I've seen some pretty elaborate answer for the challenge even tho i think that one is solvable with the least number of characters haha
it's like a trick challenge
Blauelf
@Blauelf
Sep 08 2015 12:34
BTW, I love how ES2015 allows me to write x=>x instead of function(x){return x} :)
Rory Smith
@alanbuchanan
Sep 08 2015 12:34
@Blauelf what do you use to write ES2015? babel?
DorSarel
@DorSarel
Sep 08 2015 12:35
@dting @awesomeaniruddh @Blauelf @awesomeaniruddh Thnak you all - its worked
Gary Wong
@gary-w
Sep 08 2015 12:35
awesome how Gitter’s message keep popping up… esp when I want to slack off from coding, I know someone else in the world is also coding and i also have to work hard :)
DorSarel
@DorSarel
Sep 08 2015 12:35
@dting @awesomeaniruddh @Blauelf @awesomeaniruddh Thank you!
CamperBot
@camperbot
Sep 08 2015 12:35
dorsarel sends brownie points to @dting and @awesomeaniruddh and @blauelf and @awesomeaniruddh :sparkles: :thumbsup: :sparkles:
:star: 264 | @blauelf | http://www.freecodecamp.com/blauelf
:star: 374 | @awesomeaniruddh | http://www.freecodecamp.com/awesomeaniruddh
:star: 1055 | @dting | http://www.freecodecamp.com/dting
:star: 374 | @awesomeaniruddh | http://www.freecodecamp.com/awesomeaniruddh
Blauelf
@Blauelf
Sep 08 2015 12:36
Don't really know what works in the background here, but most coding sites have added at least some ES2015 support these days, some explicitly naming babel.
DTing
@dting
Sep 08 2015 12:38

even with out arrow functions

function bouncer(arr) {
  return arr.filter(Boolean);
}

is pretty short haha

@DorSarel nice
Rory Smith
@alanbuchanan
Sep 08 2015 12:40
@Blauelf what do you think of the new class approach in ES2015? i've heard mixed opinions
Blauelf
@Blauelf
Sep 08 2015 12:40
const bouncer=(arr)=>arr.filter(x=>x); is probably shorter. But yes, this is a nice use of Boolean function. It is useless in most places, but here it is nice.
@alanbuchanan I have not used it yet, so I only read those mixed opinions ;) Class in any way has always felt strange in Javascript.
@dting I usually skip Boolean altogether and convert by adding !! in front. Would not work here.
DTing
@dting
Sep 08 2015 12:45
ya i've never use Boolean
Dominic Imbuga
@Domminique
Sep 08 2015 12:52
help here please ..var myArray = ["John", 23, ["cat", 2]]; myArray.pop();
var removed = myArray;.. how do i have myArray to only have the first two values left(["cat"], 2)?
CamperBot
@camperbot
Sep 08 2015 12:52
no wiki entry for: here please var myarray john 23 cat 2 how can i get
:pencil: click here to create one now!after creating your page type update to reload it here
Rory Smith
@alanbuchanan
Sep 08 2015 12:52
Bonfire: Steamroller i'm getting so tempted to use a regex for this, i can't figure it out. my approach is 'while the element being tested is an array, un-nest it one level', but i can't see why it's not un-nesting
CamperBot
@camperbot
Sep 08 2015 12:52
Sorry, can't find a bonfire called steamrollerhttpwwwfreecodecampcomchallengesbonfire-steamroller im getting so tempted to use a regex for this i cant figure it out my approach is while the element being tested is an array un-nest it one level but i cant figure it out. [ Check the map? ]
DTing
@dting
Sep 08 2015 12:56
bf steamroller
CamperBot
@camperbot
Sep 08 2015 12:56

:fire:Bonfire: Steamroller :link:

function steamroller(arr) {
  // I'm a steamroller, baby
  return arr;
}

steamroller([1, [2], [3, [[4]]]]);

Flatten a nested array. You must account for varying levels of nesting.

more info:  bf details | bf links | hint

Dominic Imbuga
@Domminique
Sep 08 2015 12:59
help here please ..var myArray = ["John", 23, ["cat", 2]]; myArray.pop();
var removed = myArray;.. how do i have myArray to only have the first two values left(["cat"], 2)?
CamperBot
@camperbot
Sep 08 2015 12:59
no wiki entry for: here please var myarray john 23 cat 2 myarraypopvar removed myarray how do i have myarray to only have the first two values leftcat 2
:pencil: click here to create one now!after creating your page type update to reload it here
DTing
@dting
Sep 08 2015 12:59
I used recursion for that steamroller one.
@Domminique they want you to assign the value that you popped off myArray to removed
Elizabeth Hatleli
@TheHighPriestess
Sep 08 2015 13:00
@dting ok..thanks :)
CamperBot
@camperbot
Sep 08 2015 13:00
thehighpriestess sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1056 | @dting | http://www.freecodecamp.com/dting
Blauelf
@Blauelf
Sep 08 2015 13:00
@Domminique pop() might be part of your window title ;)
DTing
@dting
Sep 08 2015 13:01
bf links
CamperBot
@camperbot
Sep 08 2015 13:01
Roy
@CruelCoin
Sep 08 2015 13:04
I'm going through the GitHub section, and i can't help but think that this is all a massive list of unintuitive commands that can be done via the lovely desktop GitHub application.
Why are we doing it via command line?
Hans van Riet
@hansinla
Sep 08 2015 13:05
@CruelCoin My thoughts exactly
DTing
@dting
Sep 08 2015 13:06
so you dont have to rely on the desktop app. also git can be used without github
Blauelf
@Blauelf
Sep 08 2015 13:07
I think the steamroller one is best solved with recursion. Yes, one could unroll it iteratively, but this makes the code look messier. At least my non-recursive approach looks messy:
function steamroller(arr) {
  var res=arr.slice();
  while (res.some(Array.isArray))
    res=res.reduce((a,e)=>Array.isArray(e)?a.concat(e):a.concat([e]),[]);
  return res;
}
Roy
@CruelCoin
Sep 08 2015 13:09

@dting

But it's redundant. Take this note for example:

" A note:

If you have GitHub for Windows on your computer, a remote named 'origin' is automatically created. In that case, you'll just need to tell it what URL to associate with origin. Use this command instead of the 'add' one above:
$ git remote set-url origin <URLFROMGITHUB> "

Its extra uneeded commands that the GitHub program would other wise manage for you?

Mbos95
@Mbos95
Sep 08 2015 13:10
  var array = arr.split('');
This returns "arr.split is not a function"
bf mutations
CamperBot
@camperbot
Sep 08 2015 13:10

:fire:Bonfire: Mutations :link:

function mutation(arr) {
  return arr;
}

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

Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.

more info:  bf details | bf links | hint

Mbos95
@Mbos95
Sep 08 2015 13:10
hint
CamperBot
@camperbot
Sep 08 2015 13:10
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Demetris Gourtzilidis
@DemetriG
Sep 08 2015 13:11

in "Bonfire: Title Case a Sentence"

```

```function titleCase(str) {
var i=0, b=null;

var a = str.split(' ');
for (i=0, i < a.length, i++) {
b += a[i].charAt(0).toUpperCase('') + str.substring(1, str.length).toLowerCase('');
}

return str;
}

titleCase("I'm a little tea pot");
```

Blauelf
@Blauelf
Sep 08 2015 13:11
@Mbos95 Then arr is probably not a string, but an array of strings ;)
Demetris Gourtzilidis
@DemetriG
Sep 08 2015 13:11
is this ok?
Mbos95
@Mbos95
Sep 08 2015 13:14
@Blauelf Ah yes. oke. the split is only for strings i suppose
DTing
@dting
Sep 08 2015 13:14
@CruelCoin what if you are on a computer with out the github app? its like why people learn css even if they plan on using less. or learning javascript when they will use coffee script.
Blauelf
@Blauelf
Sep 08 2015 13:14
@DemetriG It does not work as expected, if this is what you mean. You should use a[i] in both cases, and not add to b but assign to a[i], and use join(' ') in the return statement.
Demetris Gourtzilidis
@DemetriG
Sep 08 2015 13:16
a.join() ? @Blauelf
Blauelf
@Blauelf
Sep 08 2015 13:16
Yes :)
DTing
@dting
Sep 08 2015 13:17
@DemetriG you should start b with an emptry string not null
b = '';
Blauelf
@Blauelf
Sep 08 2015 13:17
This is the other way, but then he would have to take care of the spaces. join() is easier.
DTing
@dting
Sep 08 2015 13:17
oh sorry
you split your string.
nm ya start your b var with an emptry string and return it instead of str
Blauelf
@Blauelf
Sep 08 2015 13:18
It is perfectly possible to use b='', b += ' '+... and return b.substr(1).
DTing
@dting
Sep 08 2015 13:19
why would you return b.substr(1)?
Blauelf
@Blauelf
Sep 08 2015 13:19
To suppress the leading space.
DTing
@dting
Sep 08 2015 13:19
what leading space?
oh i see
Blauelf
@Blauelf
Sep 08 2015 13:20
You would have to add a space in front of every word, or at the end. b.substr(1) removes the first character.
Demetris Gourtzilidis
@DemetriG
Sep 08 2015 13:21
I'm lost :P
Mbos95
@Mbos95
Sep 08 2015 13:21
Hey guys, how to make string in an array go to lowercase? I am flabbergasted
DTing
@dting
Sep 08 2015 13:21
if you are building a string you need to put spaces between the words
Mbos95
@Mbos95
Sep 08 2015 13:21
And I also used this as an excuse to use the word flabbergasted
Blauelf
@Blauelf
Sep 08 2015 13:21
The split()->map() or iterate manually->join() approach just looks cleaner.
DTing
@dting
Sep 08 2015 13:22
if you choose to add the space to all the words (either before or after) you would have to remove either a trailing or leading space
gts00k
@gts00k
Sep 08 2015 13:23
var app = angular.module('myApp', []);

//Get JSON , Angular style.
app.controller('MainCtrl', function($scope, $http) {
  $http.get("https://api.twitch.tv/kraken/streams/freecodecamp")
  .success(function (response) {
    console.log(response);

  });
});
CamperBot
@camperbot
Sep 08 2015 13:23
:trollface: troll problems? notify admins here
gts00k
@gts00k
Sep 08 2015 13:23
this doesn't work
I get error message
XMLHttpRequest cannot load https://api.twitch.tv/kraken/streams/freecodecamp. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access.
kioufhs
@kioufhs
Sep 08 2015 13:23
hello, its my first bonfire, any help?
Dealga McArdle
@zeffii
Sep 08 2015 13:23
this permutations bonfire is getting on my nerves
Blauelf
@Blauelf
Sep 08 2015 13:24
@Mbos95 You mean something like ['A','B','CD'].map(String.toLowerCase);?
vijaypalmanit
@vijaypalmanit
Sep 08 2015 13:24
can someone help me how to generate random umbers between 0-9, i am trying this but not able to proceed further return Math.floor(Math.random() * 10) + 0);
kioufhs
@kioufhs
Sep 08 2015 13:24
just any idea, for start
gts00k
@gts00k
Sep 08 2015 13:24
@kioufhs you sound greek
Mbos95
@Mbos95
Sep 08 2015 13:24
i... i suppose so xD
kioufhs
@kioufhs
Sep 08 2015 13:24
@gts00k yes sir
Dealga McArdle
@zeffii
Sep 08 2015 13:24
does it mean for aab , that really they are looking for all permutations of 'a','b' that is 3 characters long and has no repeats?
gts00k
@gts00k
Sep 08 2015 13:24
@kioufhs lol greek too
Hans van Riet
@hansinla
Sep 08 2015 13:25
@dting That’s not really an argument. If you prefer github app and the computer you’re on doesn’t have it, you just install it. IMO it’s analogues to using VIm as your editor. You can and you’re a hero if you do, but why would you? You’ll still need to understand the basic principles of git, the cumbersome commands are just hidden from the user. I would say use the best tools available to get the same work done.
Blauelf
@Blauelf
Sep 08 2015 13:25
@zeffii With aba and aba being the two solutions :D
Abhisek Pattnaik
@abhisekp
Sep 08 2015 13:26
I've a question about Unit Testing. DM?
vijaypalmanit
@vijaypalmanit
Sep 08 2015 13:26
can someone help me how to generate random umbers between 0-9, i am trying this but not able to proceed further return Math.floor(Math.random() * 10) + 0);
Dealga McArdle
@zeffii
Sep 08 2015 13:26
how is ['aba', 'aba'] valid?! surely that's just ['aba' then ?
i was thinking ['aba', 'bab']
srishi2110git
@srishi2110git
Sep 08 2015 13:26
Give the text input in your form the class form-control
Dealga McArdle
@zeffii
Sep 08 2015 13:26
the question doesn't make sense to me.
srishi2110git
@srishi2110git
Sep 08 2015 13:26
what does it mean
above line
by me
Moisés Man
@moigithub
Sep 08 2015 13:27
@zeffii if the first a were 1
and the second a were 3
it wil make 123 /321 permutation
Blauelf
@Blauelf
Sep 08 2015 13:27
@zeffii All permutations, with the two a being different. A blue and a red 'a', you just can't see it.
Dealga McArdle
@zeffii
Sep 08 2015 13:27
it would be great if the bonfie included the full set of permutations for the suggested example
kioufhs
@kioufhs
Sep 08 2015 13:28
@gts00k filos mporeis na voi8iseis?
Dealga McArdle
@zeffii
Sep 08 2015 13:28
aaaaaaaaaaaaaaaaaaaaaaaahhh ha!
Moisés Man
@moigithub
Sep 08 2015 13:28
so its per position.. ignore the value...
Dealga McArdle
@zeffii
Sep 08 2015 13:28
that's a terrible bonfire.
at least... as far as explanation goes.
thanks guys
CamperBot
@camperbot
Sep 08 2015 13:28
if you want to thank someone, put an @ before their name!
srishi2110git
@srishi2110git
Sep 08 2015 13:28

Give the text input in your form the class form-control

can anyone tell me

gts00k
@gts00k
Sep 08 2015 13:28
@dting lol
srishi2110git
@srishi2110git
Sep 08 2015 13:28
??
Dealga McArdle
@zeffii
Sep 08 2015 13:28
and galls.
Mbos95
@Mbos95
Sep 08 2015 13:28
@zeffii You'll never forget it if you struggle wit hit for a long long time xD
gts00k
@gts00k
Sep 08 2015 13:29
@kioufhs lol
kioufhs
@kioufhs
Sep 08 2015 13:30
function reverseString(str) {
  return str;
}

reverseString('hello');
DTing
@dting
Sep 08 2015 13:30
@hansinla to each their own. its just another tool. just like you can ssh and use vim to edit files on headless servers.
kioufhs
@kioufhs
Sep 08 2015 13:30
help :)
CamperBot
@camperbot
Sep 08 2015 13:30

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. ex: find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • bonfire BONFIRENAME info on a bonfire

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

DTing
@dting
Sep 08 2015 13:30
you cant always install an ide or whatever editor whereever you want.
gts00k
@gts00k
Sep 08 2015 13:30
@dting your link didnt help