These are chat archives for FreeCodeCamp/Help

8th
Aug 2015
Bill
@kirah1314
Aug 08 2015 00:00
help monkey
CamperBot
@camperbot
Aug 08 2015 00:00

: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.
 

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

Bill
@kirah1314
Aug 08 2015 00:05
help reverse
CamperBot
@camperbot
Aug 08 2015 00:05

:point_right: bonfire reverse a string [wiki]

Our goal for this bonfire is to reverse the provided string just like the image. There are 4 green checks (objectives) our code needs to pass in order to complete this bonfire:

  1. The final object is expected to be a string
  2. "hello" is expected to be "olleh"
  3. "Howdy" is expected to be "ydowH"
  4. "Greetings from Earth" is expected to be "htraE morf sgniteerG"
     

:pencil: read more about bonfire reverse a string on the FCC Wiki

Bill
@kirah1314
Aug 08 2015 00:10
help bonfire
CamperBot
@camperbot
Aug 08 2015 00:10

:point_right: bonfire factorialize a number [wiki]

You should make sure to try hard to solve the Bonfire yourself before reading this!

:link: Original Bonfire :point_right:

:pencil: read more about bonfire factorialize a number on the FCC Wiki

Bill
@kirah1314
Aug 08 2015 00:10
help largest
CamperBot
@camperbot
Aug 08 2015 00:10
no wiki entry for: largest
:pencil: click here to create one now!after creating your page type update to reload it here
Steven Parker
@Philosophist
Aug 08 2015 00:11

Quick question, in the functional programming, I came across this code as a solution:

function() {
    var videos = [
        {
            "id": 65432445,
            "title": "The Chamber"
        },
        {
            "id": 675465,
            "title": "Fracture"
        },
        {
            "id": 70111470,
            "title": "Die Hard"
        },
        {
            "id": 654356453,
            "title": "Bad Boys"
        }
    ];

    // Expecting this output...
    // [
    //     {
    //         "65432445": "The Chamber",
    //         "675465": "Fracture",
    //         "70111470": "Die Hard",
    //         "654356453": "Bad Boys"
    //     }
    // ]
    return videos.
        reduce(function(accumulatedMap, video) {

            // Object.create() makes a fast copy of the accumulatedMap by
            // creating a new object and setting the accumulatedMap to be the
            // new object's prototype.
            // Initially the new object is empty and has no members of its own,
            // except a pointer to the object on which it was based. If an
            // attempt to find a member on the new object fails, the new object
            // silently attempts to find the member on its prototype. This
            // process continues recursively, with each object checking its
            // prototype until the member is found or we reach the first object
            // we created.
            // If we set a member value on the new object, it is stored
            // directly on that object, leaving the prototype unchanged.
            // Object.create() is perfect for functional programming because it
            // makes creating a new object with a different member value almost
            // as cheap as changing the member on the original object!

            var copyOfAccumulatedMap = Object.create(accumulatedMap);

            copyOfAccumulatedMap[video.id] = video.title;

            return copyOfAccumulatedMap;
        },
        // Use an empty map as the initial value instead of the first item in
        // the list.
        {});
}

I'm confused as to how the output is supposedly


    // [
    //     {
    //         "65432445": "The Chamber",
    //         "675465": "Fracture",
    //         "70111470": "Die Hard",
    //         "654356453": "Bad Boys"
    //     }
    // ]

And not

    // [
    //     {
    //         "id": "The Chamber",
    //         "id": "Fracture",
    //         "id": "Die Hard",
    //         "id": "Bad Boys"
    //     }
    // ]
Or even,
[
        {
            "id": "TheChamber",
            "title": "The Chamber"
        },
        {
            "id": "Fracture",
            "title": "Fracture"
        },
        {
            "id": "Die Hard",
            "title": "Die Hard"
        },
        {
            "id": "Bad Boys",
            "title": "Bad Boys"
        }
    ]
Steven Parker
@Philosophist
Aug 08 2015 00:19
I could use some clarification if anyone can explain.
Mary
@marycontrary
Aug 08 2015 00:19
bonfire sorted union
CamperBot
@camperbot
Aug 08 2015 00:19

:fire:Bonfire: Sorted Union :link:

function unite(arr1, arr2, arr3) {
  return arr1;
}

unite([1, 2, 3], [5, 2, 1, 4], [2, 1]);

Write a function that takes two or more arrays and returns a new array of unique values in the order of the original provided arrays.
In other words, all values present from all arrays should be included in their original order, but with no duplicates in the final array.
The unique numbers should be sorted by their original order, but the final array should not be sorted in numerical order.
Check the assertion tests for examples.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

type: bf details bf links bf spoiler

Mary
@marycontrary
Aug 08 2015 00:19
bf details
CamperBot
@camperbot
Aug 08 2015 00:19

:fire:Bonfire: Sorted Union :link:

function unite(arr1, arr2, arr3) {
  return arr1;
}

unite([1, 2, 3], [5, 2, 1, 4], [2, 1]);
Write a function that takes two or more arrays and returns a new array of unique values in the order of the original provided arrays.
In other words, all values present from all arrays should be included in their original order, but with no duplicates in the final array.
The unique numbers should be sorted by their original order, but the final array should not be sorted in numerical order.
Check the assertion tests for examples.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.
links:
DTing
@dting
Aug 08 2015 00:20
@Philosophist the reduce callback makes a copy of the previous value. so you start with {} as the previous value. you make a copy of that. then you set that copies video.id key to video.title.
That value is returned. then the process repeats except now the previous value is {'<video.id>':'<video.title>'}.
DTing
@dting
Aug 08 2015 00:25
calling reduce on the videos array means that the callback is called with each value in the videos array you can think of it as:
var result = {};
for (var i = 0; i < videos.length; i++) {
  var video = videos[i];
  result[video.id] = video.title;
} 
return result;
Steven Parker
@Philosophist
Aug 08 2015 00:38
Oh, so it's taking video.id as the position in the {} in the array? Like some other earlier examples which had missing number values or number values out of order? And result[] = is another way of writing a sort of push function into {}?

Are "{}" (set?) values always able to operate like that? Like, could

result[video[0]] = video[1];

have worked?

Steven Parker
@Philosophist
Aug 08 2015 00:44
@dting
DTing
@dting
Aug 08 2015 00:46
@Philosophist video doesnt have a 0 or 1 property. see http://www.w3schools.com/js/js_properties.asp
Steven Parker
@Philosophist
Aug 08 2015 00:55

@dting Hmm, I see. it's the other use of [] for properties that threw me off.

result[video[id]] = video[title];

would have worked, right?

DTing
@dting
Aug 08 2015 00:56
@Philosophist video['id'] and video['title']
DTing
@dting
Aug 08 2015 01:02
but most people try to avoid using bracket notation when you can use the dot notation unless you have too. For example:
var a = {'1': 2, '1a': 3, '.b': 4}

// throws
a.1
// okay
a['1']

// throws
a.1a
// okay
a['1a']

// throws
a..b
// okay
a['.b']
Bill
@kirah1314
Aug 08 2015 01:06
@dcsan here ^
help reverse
CamperBot
@camperbot
Aug 08 2015 01:06

:point_right: bonfire reverse a string [wiki]

Our goal for this bonfire is to reverse the provided string just like the image. There are 4 green checks (objectives) our code needs to pass in order to complete this bonfire:

  1. The final object is expected to be a string
  2. "hello" is expected to be "olleh"
  3. "Howdy" is expected to be "ydowH"
  4. "Greetings from Earth" is expected to be "htraE morf sgniteerG"
     

:pencil: read more about bonfire reverse a string on the FCC Wiki

Komal Bhandari
@panaroma
Aug 08 2015 01:08
any one willing to wake me through Bonfire Where art though?
Kolloom
@Kolloom
Aug 08 2015 01:08
how do i compare 2 near identical arrays and outputs the different elements? eg. f([1,2,3,4] , [1,2,3,4,5]) = 5
@panaroma I could try
Bill
@kirah1314
Aug 08 2015 01:09
@Kolloom reduce can do that
Kolloom
@Kolloom
Aug 08 2015 01:10
don't know exactly how @kirah1314
Bill
@kirah1314
Aug 08 2015 01:10
@Kolloom oops i'm thinking of filter, sorry
check out the filter method
Kolloom
@Kolloom
Aug 08 2015 01:11
find filter
CamperBot
@camperbot
Aug 08 2015 01:11

find filter

[0] js filter

Kolloom
@Kolloom
Aug 08 2015 01:11
still don't know how to design the callback function though
Jared Abel
@jaredabel
Aug 08 2015 01:12
@panaroma Hardest bonfire there is, easily
Bill
@kirah1314
Aug 08 2015 01:12
combine filter with indexof
CamperBot
@camperbot
Aug 08 2015 01:12
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Kolloom
@Kolloom
Aug 08 2015 01:12
got it
Kolloom
@Kolloom
Aug 08 2015 01:20
never mind i didn't get it
would not work if both list have unique elements
deaninous
@deaninous
Aug 08 2015 01:23
and here I am again. looking for help. Ayone upfor checking what is so wrong with my code?
var rectangle = new Object()
rectangle.height = 3;
rectangle.width = 4;

// here is our method to set the height
var rectangle.setHeight = function (newHeight) {
  this.height = newHeight;

};
var rectangle.setWidth = function(newWidth){
    this.width = newWidth;
};


// help by finishing this method
rectangle.setWidth = setWidth;
rectangle.setHeight = setHeight;


// here change the width to 8 and height to 6 using our new methods
rectangle.setWidth(8);
rectangle.setHeight(6);
Kolloom
@Kolloom
Aug 08 2015 01:23
any error msgs?
deaninous
@deaninous
Aug 08 2015 01:26
here is what i get
SyntaxError: missing before statement
i cant seem to find out what is wrong
@Kolloom it is the chapter on Objects
DTing
@dting
Aug 08 2015 01:28
@deaninous you shouldn't be using var rectangle.set...
should just be var set...
deaninous
@deaninous
Aug 08 2015 01:29
thank you let me fix that real quick
Kolloom
@Kolloom
Aug 08 2015 01:31
I forgot this part of the js (shameful
shouldn't it be Object.functionName ?
deaninous
@deaninous
Aug 08 2015 01:32
thank you so much. it passes now like a charm @Kolloom @dting
CamperBot
@camperbot
Aug 08 2015 01:32
:star: 5 | @dting | http://www.freecodecamp.com/dting
deaninous sends brownie points to @kolloom and @dting :sparkles: :thumbsup: :sparkles:
shermola1
@shermola1
Aug 08 2015 01:33
Anyone up for double-checking my Map the Debris code? For some reason all of the calculations are off by a tiny fraction and I'm pulling my hair out trying to figure it out. I'm sure it's something trivial that I'm overlooking. Any help is appreciated! [cross-posted]
function calculateOP(altitude) {
  var GM = 398600.4419;
  var earthRadius = 6367.4447;

  return Math.round(2 * Math.PI * Math.sqrt(Math.pow((earthRadius + parseInt(altitude)), 3)/GM));
}

function orbitalPeriod(arr) {
  var tmpArr = [];

  for (var i = 0; i < arr.length; i++) {
    var objName = arr[i].name;
    var alt = parseInt(arr[i].avgAlt);
    var obj = {name: objName, orbitalPeriod: calculateOP(alt)};

    tmpArr.push(obj);
  }

  return tmpArr;
}
DTing
@dting
Aug 08 2015 01:36
@shermola1 you converted the float's to ints get rid of the parseInts and change the GM to the supplied value and it should work.
Omar
@oab00
Aug 08 2015 01:36
@shermola1 I haven't checked it myself but I think it's something to do with
parseInt(altitude) in the equation
eh ninja'd
:sweat_smile:
shermola1
@shermola1
Aug 08 2015 01:37
@dting & @oab00 Duh! I'm sure that's it, I added those early on to troubleshoot another issue and forgot to take them out. Thanks!!!
chicachicamji
@chicachicamji
Aug 08 2015 01:38
does anyone know why this code isn't returning the first letter of each element in the array?
function titleCase(str) {
  var firstArray = str.split(' ');
  for(var x = 0; x < firstArray.length; x++) {
    return x.charAt(0);
  }
}

titleCase("I'm a little tea pot");
Kolloom
@Kolloom
Aug 08 2015 01:40
str.charAt(0)
x is an iterator, always a number
chicachicamji
@chicachicamji
Aug 08 2015 01:42
ahh i see now that was stupid
SM
@nogo10
Aug 08 2015 01:44
silly question: in JS one can declare a function within a function right?
Vanessa
@monarch11
Aug 08 2015 01:45
Hey I have a question: I'm learning how to create margins.The guide says:
Kolloom
@Kolloom
Aug 08 2015 01:45
yes @nogo10
Chocobowings
@chocobowings
Aug 08 2015 01:45
@nogo10 yup
SM
@nogo10
Aug 08 2015 01:45
@Kolloom thanks ;it make use of 'global' variables within scope of functions
Vanessa
@monarch11
Aug 08 2015 01:46
Hey I have a question: I'm learning how to create margins... The guide says: Your green-box class should give elements -15px of margin. So I typed out this: Your green-box class should give elements -15px of margin. And it says it's wrong?
I mean I typed out this: .green-box {
background-color: green;
padding: 20px;
margin: -15px;
}
David Hewitt
@davidmhewitt
Aug 08 2015 01:46
Hi @monarch11 ! Which exercise is it you're doing? I'll take a look :)
Vanessa
@monarch11
Aug 08 2015 01:47
"Waypoint: Add a Negative Margin to an Element"
Cristián Berríos
@crisberrios
Aug 08 2015 01:47
@chicachicamji also, using "return" will exit the function immediatly. You might want to store the results somewhere first before returning.
chicachicamji
@chicachicamji
Aug 08 2015 01:47
yes, I know, I fixed that. Thanks.
Cristián Berríos
@crisberrios
Aug 08 2015 01:47
syntax is right at least
@monarch11
David Hewitt
@davidmhewitt
Aug 08 2015 01:48
@monarch11 yep, looks correct. Try editing it and putting it back to that. It might just have bugged out and not picked up what you've done is correct.
chicachicamji
@chicachicamji
Aug 08 2015 01:49
Does anyone know why this isn't return the first letter of every word in an array?
function titleCase(str) {
  var firstArray = str.split(' ');
  var yes;
  for(var x = 0; x < firstArray.length; x++) {
    yes = firstArray[x].charAt(0).toUpperCase();
  }
  return yes;
}

titleCase("I'm a little tea pot");
Cristián Berríos
@crisberrios
Aug 08 2015 01:49
@nogo10 you can use "global" (or more correctly, within scope) functions within other functions. And also return functions that will "remember" the context on which they were created. That's the beauty of closures
David Hewitt
@davidmhewitt
Aug 08 2015 01:50
@chicachicamji Your return statement returns only 1 value. So that code will return the first letter of the last word of the array.
Cristián Berríos
@crisberrios
Aug 08 2015 01:50
@chicachicamji it's because for each iteration you are overwriting the variable "yes".
Also, read the instructions well as it doesn't seem you are trying to do the right thing.
David Hewitt
@davidmhewitt
Aug 08 2015 01:51
@chicachicamji That bonfire wants you to return a string with the first letter of every word capitalised. So you have to find a way to rebuild/edit the string, not return the capitalised letters.
Cristián Berríos
@crisberrios
Aug 08 2015 01:51
Still, if what you want is returning the 1st letter of each array
do the following changes: replace yes for var yes=[];
then instead of yes = ..... do yes.push(....)
chicachicamji
@chicachicamji
Aug 08 2015 01:52
ohhh that makes sense @davidmhewitt @crisberrios and I know, I'm just testing this so it works before I return the string with each letter capitalized
Cristián Berríos
@crisberrios
Aug 08 2015 01:53
push will add new results to the end of the array as a new entry
Vanessa
@monarch11
Aug 08 2015 01:53
@davidmhewitt it didn't work, so I switched from google chrome to firefox and it finally worked
David Hewitt
@davidmhewitt
Aug 08 2015 01:54
@monarch11 Hmm, weird. Either way, it's good to have that reassurance that it wasn't you doing something wrong!
Bill
@kirah1314
Aug 08 2015 01:54
help palind
CamperBot
@camperbot
Aug 08 2015 01:54
no wiki entry for: palind
:pencil: click here to create one now!after creating your page type update to reload it here
alf maglalang
@alf808
Aug 08 2015 01:55
i'm about to do the camper news zipline. Does someone know what the points mean on a news item at http://www.freecodecamp.com/news ? How does a news item get points and why?
David Hewitt
@davidmhewitt
Aug 08 2015 01:56
@alf808 My first thought would be it's something a bit like reddit where upvoted content floats to the top. However, I don't see anywhere to do the upvoting, so I'm not sure.
alf maglalang
@alf808
Aug 08 2015 01:58
@davidmhewitt for the first time I (half)understood reddit today. I'm still not sure. It's confusing how the points are earned on freecodecamp news
David Hewitt
@davidmhewitt
Aug 08 2015 01:59
@alf808 yes! there is an upvote button. I found it. So yes, people vote on articles they like and it makes them appear closer to the top of the list.
@alf808 But there will be some algorithm to ensure new articles appear closer to the top as well even if they have less votes.
alf maglalang
@alf808
Aug 08 2015 02:01
@davidmhewitt what is the meaning of upvoting a news item? is it like "like"ing on facebook?
David Hewitt
@davidmhewitt
Aug 08 2015 02:02
Yes, exactly the same really. Facebook puts comments with lots of likes nearer to the top too.
alf maglalang
@alf808
Aug 08 2015 02:03
@davidmhewitt thank you. I understand.
David Hewitt
@davidmhewitt
Aug 08 2015 02:03
@alf808 no problem! Good luck with your zipline
chicachicamji
@chicachicamji
Aug 08 2015 02:03
does anyone know if you have to use regular expressions in the "Title Case a Sentence" Bonfire?
nevermind
Bill
@kirah1314
Aug 08 2015 02:04
@chicachicamji you can do it with charAt() method
alf maglalang
@alf808
Aug 08 2015 02:04
@davidmhewitt thanks. i need the luck. they are not easy.
Bill
@kirah1314
Aug 08 2015 02:05
help title case
CamperBot
@camperbot
Aug 08 2015 02:05
no wiki entry for: title case
:pencil: click here to create one now!after creating your page type update to reload it here
David Hewitt
@davidmhewitt
Aug 08 2015 02:06
@alf808 Yes, I did my first zipline today. Starting the weather one tomorrow
Michael Christofersen
@mchristofersen
Aug 08 2015 02:07
anybody done Bonfire: Convert HTML Entities?
CamperBot
@camperbot
Aug 08 2015 02:07
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Michael Christofersen
@mchristofersen
Aug 08 2015 02:07
bonfire Convert HTML Entities
CamperBot
@camperbot
Aug 08 2015 02:07

:fire:Bonfire: Convert HTML Entities :link:

function convert(str) {
  // &colon;&rpar;
  return str;
}

convert('Dolce & Gabbana');

Convert the characters "&", "<", ">", '"' (double quote), and "'" (apostrophe), in a string to their corresponding HTML entities.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

type: bf details bf links bf spoiler

Bill
@kirah1314
Aug 08 2015 02:08
@mchristofersen yes, need help?
Robert
@rc242
Aug 08 2015 02:08
@mchristofersen Go ahead and ask the question. Someone will respond.
Michael Christofersen
@mchristofersen
Aug 08 2015 02:08
yea I just don't understand exactly how they want the output because it prints what it expects in html...
Bill
@kirah1314
Aug 08 2015 02:09
ah ok, yeah it's confusing. I had the same question too lol
Michael Christofersen
@mchristofersen
Aug 08 2015 02:09
for instance expected 'Hamburgers < Pizza < Tacos' to equal 'Hamburgers < Pizza < Tacos'
Bill
@kirah1314
Aug 08 2015 02:09
basically you want &amp;
as the output
Rafael J. Rodriguez
@Rafase282
Aug 08 2015 02:09
where could I get live help for github?
Michael Christofersen
@mchristofersen
Aug 08 2015 02:09
i'm using ['&#38','&quot','&lt','&gt','&apos'] for ["&",'"',"<",">","'"]
Chocobowings
@chocobowings
Aug 08 2015 02:10
@mchristofersen Include the semicolon
Bill
@kirah1314
Aug 08 2015 02:10
yeah, missing ;
Michael Christofersen
@mchristofersen
Aug 08 2015 02:10
ahh thanks
Bill
@kirah1314
Aug 08 2015 02:10
@mchristofersen :thumbsup:
Michael Christofersen
@mchristofersen
Aug 08 2015 02:11
wait so something like '"'?
pwdd
@pwdd
Aug 08 2015 02:11
Hi, anyone here can help me with this infinite loop on Bonfire: Chunky Monkey?

function chunk(arr, size) {
// create an empty array to where elements will be pushed in
var splited = [];
// while there is any element on array
while (arr) {
// if size is bigger or equal to array length
if (size >= arr.length) {
// push slice part from arr into splited
splited.push(arr.slice(0, size));
// remove part from original arr
arr.splice(0, size);
}
}

return splited;
}

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

AJ Gibson
@gibsonio
Aug 08 2015 02:11
for the mutations Bonfire, is there an easier way than this below?
function mutation(arr) {


  result = true;

  var firstWord = arr[0].toLowerCase().split(""); 
  var secondWord = arr[1].toLowerCase().split(""); 
  var storage = [];


  for(var i = 0; i < secondWord.length; i++) {

          storage.push(firstWord.indexOf(secondWord[i]));     
  }


    for(j = 0; j < storage.length; j++) {

        if(storage[j] < 0) {

          result = false;
        }
    }

    return result;
  }  


mutation(['hello', 'hey']);
Robert
@rc242
Aug 08 2015 02:11
function chunk(arr, size) {
  // create an empty array to where elements will be pushed in
  var splited = [];
  // while there is any element on array
  while (arr) {
    // if size is bigger or equal to array length
    if (size >= arr.length) {
      // push slice part from arr into splited
      splited.push(arr.slice(0, size));
      // remove part from original arr
      arr.splice(0, size);
    }
  }

  return splited;
}

chunk(['a', 'b', 'c', 'd'], 2);
Well, that's some interesting markup.
@pwdd You'll need to review the condition of your while loop.
Bill
@kirah1314
Aug 08 2015 02:14
@gibsonio FYI,

function mutation(arr) {

 var str1 = arr[0].toLowerCase();
 var str2 = arr[1].toLowerCase();

  for (i = 0; i < str2.length; i++) {

  if (str1.indexOf(str2[i]) === -1) {
        return false;
    } 
  }
    return true;
  }
mutation(['hello', 'hey']);
pwdd
@pwdd
Aug 08 2015 02:14
while there is array && arr.length is bigger than size, maybe?
Robert
@rc242
Aug 08 2015 02:14
bonfire Mutations
CamperBot
@camperbot
Aug 08 2015 02:14

: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.
For example, ['hello', 'Hello'], should return true because all of the letters in the second string are present in the first, ignoring case.
The arguments ['hello', 'hey'] should return false because the string 'hello' does not contain a 'y'.
Lastly, ['Alien', 'line'], should return true because all of the letters in 'line' are present in 'Alien'.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

type: bf details bf links bf spoiler

Michael Christofersen
@mchristofersen
Aug 08 2015 02:15
thanks everyone
Bill
@kirah1314
Aug 08 2015 02:17
help chunk
CamperBot
@camperbot
Aug 08 2015 02:17

: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.
 

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

Robert
@rc242
Aug 08 2015 02:17
@gibsonio you could make an set, too.
AJ Gibson
@gibsonio
Aug 08 2015 02:18
@kirah1314 wow i feel really stupid now lol. can't believe i didn't think of that at all smh
Bill
@kirah1314
Aug 08 2015 02:18
@gibsonio no worries, took me a while too :)
Robert
@rc242
Aug 08 2015 02:19
@kirah1314 there's very little difference if any between using indexOf and having another for-loop inside your for-loop.
pwdd
@pwdd
Aug 08 2015 02:19
tks, I'll check the wiki on chunky monkey!
Robert
@rc242
Aug 08 2015 02:20
@kirah1314 n/m. i was looking at your code wrong.
@kirah1314 er, I meant to send that to, @gibsonio . oops.
Bill
@kirah1314
Aug 08 2015 02:22
@rc242 :thumbsup:
AJ Gibson
@gibsonio
Aug 08 2015 02:23
@rc242 no worries :)
Matt Guenther
@mguenther006
Aug 08 2015 02:23
Hi everyone. Is there anyone that would be willing to help me understand using a 'PUT’ to replace a value w. node/express?
Robert
@rc242
Aug 08 2015 02:24
@pwdd yes, going until the arr.length > size would be an approach. However, you'll need to realize that at some point you may have an array that's not divisible by size, so you may have some remaining elements left over.
Paul Dynowski
@pdynowski
Aug 08 2015 02:25
is anyone available to help me understand what i'm doing wrong with the api in the weather zipline?
pwdd
@pwdd
Aug 08 2015 02:25
@rc242 I posted again on the wrong place

function chunk(arr, size) {
// create an empty array to where elements will be pushed in
var splited = [];
// while there is array and it is bigger than size
while (arr && arr.length >= size) {
// push part of arr into splited
splited.push(arr.slice(0, size));
// delete part of arr
arr.splice(0, size);
}
// if the is remainder on arr smaller then size and bigger than 0;
if (arr.length > 0) {
splited.push(arr);
}
// return the created array
return splited;
}

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

pwdd
@pwdd
Aug 08 2015 02:26
@rc242 this is my new solution. Is this too unorthodox? or is it acceptable
@rc242 ps: how can I post code in the proper way here instead of that chunk of text?
Bill
@kirah1314
Aug 08 2015 02:27
@pwdd help format
help format
CamperBot
@camperbot
Aug 08 2015 02:27

: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

``` ⇦ Type 3 backticks, 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

pwdd
@pwdd
Aug 08 2015 02:28
thanks @kirah1314
CamperBot
@camperbot
Aug 08 2015 02:28
pwdd sends brownie points to @kirah1314 :sparkles: :thumbsup: :sparkles:
:star: 99 | @kirah1314 | http://www.freecodecamp.com/kirah1314
pwdd
@pwdd
Aug 08 2015 02:29

```function chunk(arr, size) {
// create an empty array to where elements will be pushed in
var splited = [];
// while there is array and it is bigger than size
while (arr && arr.length >= size) {
// push part of arr into splited
splited.push(arr.slice(0, size));
// delete part of arr
arr.splice(0, size);
}
// if the is remainder on arr smaller then size and bigger than 0;
if (arr.length > 0) {
splited.push(arr);
}
// return the created array
return splited;
}

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

nope :worried:
Bill
@kirah1314
Aug 08 2015 02:29
the ``` has to be their own line lol
Robert
@rc242
Aug 08 2015 02:30
@pwdd looks okay to me, but run it against the test code.
pwdd
@pwdd
Aug 08 2015 02:30
yes, it worked, @rc242 . but as it looked a bit different from the suggestions on the wiki, I wonder if it is acceptable code
thanks for looking at that for me @rc242
CamperBot
@camperbot
Aug 08 2015 02:31
pwdd sends brownie points to @rc242 :sparkles: :thumbsup: :sparkles:
Bill
@kirah1314
Aug 08 2015 02:32
@pwdd it's always good to write our own code. And then we can check out others for reference :)
Robert
@rc242
Aug 08 2015 02:34
@pwdd The main difference between splice and slice is that splice modifies the array. This may not be the appropriate approach for some input.
@pwdd ... and slice returns an array, but keeps the original array in tact.
pwdd
@pwdd
Aug 08 2015 02:35
@rc242 thanks for that. I probably should have made a copy of the original array to avoid changing it. I appreciate you taking the time to help me
Robert
@rc242
Aug 08 2015 02:36
@pwdd This is probably getting ahead of your experience on here (or as a developer), but when you're providing a "service" (e.g., a function), others may not be expecting your service to modify their input variables.
@pwdd Again, this is probably getting ahead of things, but you may want to think of local variables like this, "do I need all this data right now?" In this example, you only need the input array and chunks off it. You don't need the input array x2 at any point.
pwdd
@pwdd
Aug 08 2015 02:39
@rc242 makes sense. I'll have that in mind for next problems ;)
Robert
@rc242
Aug 08 2015 02:39
@pwdd I highly doubt the point of these exercises are about efficacy, but it's something to think about with actual development.
pwdd
@pwdd
Aug 08 2015 02:40
@rc242 time for dinner here. Thanks again! It was incredibly helpful learning these things.
see you!
DanJack30
@DanJack30
Aug 08 2015 02:46
I am trying to find a easy visitor/ip/browser tracker with php can someone help me out? I really don't know php alot :pensive: ?
Jenn
@jrg626
Aug 08 2015 03:17
Ive got a question on the second jquery waypoint.
Rockpile
@rock-pile
Aug 08 2015 03:25
@jrg626 yes whats your question?
Jenn
@jrg626
Aug 08 2015 03:28
just figured it out in the other room thanks @camgoodman!
Derik
@TubbsMcD
Aug 08 2015 03:33
Okay, so I have a super-noob question. I'm stuck on the image resizing. I have put the css style code everywhere I can think of and it's still not resizing the image.
Just trying to figure out what I'm missing or what placement point I'm missing
noob247
@noob247365
Aug 08 2015 03:34
Could you show the css for the size and the img tag? @TubbsMcD
Derik
@TubbsMcD
Aug 08 2015 03:35
.smaller-image { width: 100px; } (that's in the style brackets of course.)
<img src='https://bit.ly/fcc-kittens'/>
am I supposed to be putting the style in the imq tag?
noob247
@noob247365
Aug 08 2015 03:35
Ah, add class="smaller-image" to the img tag.
Without setting the class it's not actually doing anything
Derik
@TubbsMcD
Aug 08 2015 03:36
O sweet geebus....
thank you!
noob247
@noob247365
Aug 08 2015 03:36
Haha, the simplest things slip the mind sometimes
You're welcome :D
Derik
@TubbsMcD
Aug 08 2015 03:36
This is my first honest attempt at coding besides modifying some XML stuff for rainmeter
So I figured it was some logic issue I was missing
noob247
@noob247365
Aug 08 2015 03:37
Ah, well good for you for trying something cool :D Web dev stuffs is one of the funnest things to learn
Derik
@TubbsMcD
Aug 08 2015 03:37
Yeah I was all about hardware, but that can only get you so far lol
And thanks!
noob247
@noob247365
Aug 08 2015 03:38
You're welcome, helping people do this stuff is incredibly fun :)
John Chau
@ydjjabt
Aug 08 2015 03:41
 var streamers = ["freecodecamp", "GeoffStorbeck", "terakilobyte", "habathcx","notmichaelmcdonald","RobotCaleb","medrybw","comster404","brunofin","thomasballinger","joe_at_underflow","noobs2ninjas","mdwasp","beohoff","xenocomagain"];
  var cb = '?client_id=5j0r5b7qb7kro03fvka3o8kbq262wwm&callback=?';
    var url = 'https://api.twitch.tv/kraken/';

$(document).ready(function(){
streamers.forEach(function(stream) {

    // Temporary object
    var obj = {};

    // Check if streaming
        $.getJSON(url + 'streams/' + stream + cb),function(data) {
      console.log(data)

    });
});
  });
why doesnt it run
Ryan Malm
@Rybar
Aug 08 2015 03:44
blob
noob247
@noob247365
Aug 08 2015 03:44
@ydjjabt I answered on the main chat
Ryan Malm
@Rybar
Aug 08 2015 03:44
Hey everyone, we may be offering T-shirts soon. Would you be interested?
noob247
@noob247365
Aug 08 2015 03:44
@Rybar <3 Yes pls
Derik
@TubbsMcD
Aug 08 2015 03:46
I'd grab one of the green ones for sure!
Luis Felipe López G.
@luishendrix92
Aug 08 2015 03:47
The red one seems more fitting
Sean
@seanr707
Aug 08 2015 03:48
@Rybar I think they'd be perfect if you included a white shirt / black logo option
Derik
@TubbsMcD
Aug 08 2015 03:48
I'd get one regardless of the color, I just have a personal preference for green
Ryan Malm
@Rybar
Aug 08 2015 03:51
We would offer more than one color choice. The colors present in my mockup ^ for sure.
Derik
@TubbsMcD
Aug 08 2015 03:57
Ugh, already stuck on the next lesson, adding a border. When adding a second class do you need to separate the classes with a semicolon?
Sean
@seanr707
Aug 08 2015 03:57
no, `class='aclass bclass'
Derik
@TubbsMcD
Aug 08 2015 03:58
Ahhhh ok, so no matter how many you put in you only need the class command once, thanks
Think I might call it there for the night. Pretty sure my frustration is getting the best of me. That's the one thing I didn't try
how do i attach the logo/ico n
S. Solomon
@SHSolomon
Aug 08 2015 04:25
If I want to look at the code from a prior screen, and I go back it's not there. Is there anyway to access the code I entered on a Bonfire once I leave the page?
noob247
@noob247365
Aug 08 2015 04:28
If you submitted successfully yes, otherwise I don't think so.... @SHSolomon
Kameron Robinson
@RobinsonKameron
Aug 08 2015 04:37
Gonna go to bed soon anyone stuck on something?
@Lin-H
Aug 08 2015 04:39
night night :moon:
Kameron Robinson
@RobinsonKameron
Aug 08 2015 04:41
Night @Lin-H
wontoan
@wontoan
Aug 08 2015 04:48
Is there a good book/resource on algorithms (preferably using Javascript)? I'm really struggling with the Basic Algorithm Scripting bonfires.
Kameron Robinson
@RobinsonKameron
Aug 08 2015 04:50
@wontoan did you finish codecademy javaScripting course?
wontoan
@wontoan
Aug 08 2015 04:52
@RobinsonKameron I've done everything in order according to FCC maps. Is that part of it?
I'm currently on Roman Numerals but I basically solved that bonfire hardcoding each value into a switch statement (not optimal at all)
CamperBot
@camperbot
Aug 08 2015 04:53
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Kameron Robinson
@RobinsonKameron
Aug 08 2015 04:53
@wontoan yes, okay so send me a PM and I'll send you a link to a repo of good books to download
@wontoan do you read the documentation?
In the more info section
wontoan
@wontoan
Aug 08 2015 04:55
I do but I have trouble understanding how they explain it.
Kameron Robinson
@RobinsonKameron
Aug 08 2015 04:56
Anytime I don't get it I watch a couple YouTube videos to see the implementation.
wontoan
@wontoan
Aug 08 2015 04:57
Never thought about that
Kameron Robinson
@RobinsonKameron
Aug 08 2015 04:57
Or just try to implement it in a very small way before application it to the algorithm
Applying*
Steven Parker
@Philosophist
Aug 08 2015 05:10
@dting Awesome, that makes more sense. Thank you!
David Failla
@davidfaillaii
Aug 08 2015 05:14
Hi all. I was working on Bonfire: Seek and Destroy yesterday, which I was eventually able to successfully code. But I didn't use an Array.filter()
Can someone help show me how you would use an Array.filter() in this situation?
Rex Schrader
@SaintPeter
Aug 08 2015 05:15
@davidfaillaii Sure
@davidfaillaii Do you want to share your code, or just get a general description of how .filter works?
or, I guess, how it applies?
David Failla
@davidfaillaii
Aug 08 2015 05:16
Yes, how it applies
Rex Schrader
@SaintPeter
Aug 08 2015 05:17
ok, so if you break down the problem it it's most elemental parts, what you're doing is deciding if a number stays or goes from an array, right?
David Failla
@davidfaillaii
Aug 08 2015 05:17
I understand the theory of how the .filter works, but couldn't figure out/ get it to work in this situation.
wontoan
@wontoan
Aug 08 2015 05:17
@davidfaillaii .filter simply replaces the for loop and .push in one step.
Rex Schrader
@SaintPeter
Aug 08 2015 05:17
With array.filter, you can process each element in an array and, if you return 'true' it keeps the value and 'false' it leaves the value out
So, yeah, what @wontoan said - it just simplifies the loop. No need for an itterator and no need for a temp array to store the answer in
David Failla
@davidfaillaii
Aug 08 2015 05:20
is .filter always used with .filter(function(){.......?
Ross Kaffenberger
@rossta
Aug 08 2015 05:20
@davidfaillaii usually like that, yes
Rex Schrader
@SaintPeter
Aug 08 2015 05:20
@davidfaillaii mostly, but not always. You can define your filter function elsewhere in your code and just pass in the function name
Like this:
function filterThing(thing) {
    return thing > 5;
}
var filtered = arr.filter(filterThing);
David Failla
@davidfaillaii
Aug 08 2015 05:22
ah, ok
Rex Schrader
@SaintPeter
Aug 08 2015 05:22
The idea would be if you had a common filter that you were applying in a bunch of different places, it might make sense to define it as a function elsewhere
It can also potentially make your code more readable
Here is my S&D solution:
// Functional Programming Solution
function destroyer(arr) {
  // Get just the passed arguments
  var args = Array.prototype.slice.call(arguments,1);

  return arr.filter(function(a) { return (args.indexOf(a) === -1);});
}
David Failla
@davidfaillaii
Aug 08 2015 05:25
@SaintPeter Thank you for sharing. I'm a little confused about what args.indexOf(a) === -1 is doing
wontoan
@wontoan
Aug 08 2015 05:27
array.indexOf('what you're looking for in the array');
If 'what you're looking for' is there, it'll tell you at which index it's found (array[0], array[1], etc.)
If it's not there it'll return -1.
Rex Schrader
@SaintPeter
Aug 08 2015 05:27
@davidfaillaii args from the line above is an array of all of the arguments passed in, excluding the first one (which is the array to search). .indexOf searches an array for a given value (in this case a) and, if it finds it, returns the index of that item. If it doesn't find it, it returns -1 (because, of course, 0 is a valid answer for an index in an array)
@davidfaillaii So what I've done is kinda turned the problem on it's head. Rather than searching the array for each "destroy" value, I'm instead searching the list of possible "destroy" values for each value in the array. If it's not found (indexof === -1), then it returns true, meaning that it is kept. If it were found (indexof !== -1), then we'd "destroy" it - return false and remove it from the array.
David Failla
@davidfaillaii
Aug 08 2015 05:31
ahhh, Thank you so much @SaintPeter and @wontoan
Rex Schrader
@SaintPeter
Aug 08 2015 05:31
Glad to help :D
David Failla
@davidfaillaii
Aug 08 2015 05:31
is there a way to complete this exercise without converting the arguments into an array?
Rex Schrader
@SaintPeter
Aug 08 2015 05:31
No
Pretty much anytime you have an unknown amount of arguments you're going to need to access the arguments object
David Failla
@davidfaillaii
Aug 08 2015 05:32
ok, that also confused me at first
wontoan
@wontoan
Aug 08 2015 05:32
at least you're asking questions...
Rex Schrader
@SaintPeter
Aug 08 2015 05:32
I suppose it's theoretically possible to use the 'raw' arguments object - you could, for example, use a for..in loop
wontoan
@wontoan
Aug 08 2015 05:33
it took me over 3 days to figure out that bonfire on my own lol.
Rex Schrader
@SaintPeter
Aug 08 2015 05:33
But . . meh. It would not be very clean
David Failla
@davidfaillaii
Aug 08 2015 05:34
ya, I could see that. I was trying to use for loops and started getting fairly long
Robert
@rc242
Aug 08 2015 05:41
woosh.
Rex Schrader
@SaintPeter
Aug 08 2015 05:41
Super rc242 has arrived!
SaintPeter @SaintPeter fist bumps
Robert
@rc242
Aug 08 2015 05:44
Heyo.
That feeling you get when you realize some hosting site is way too slow. :worried:
Azhagan
@Azhagan
Aug 08 2015 07:07
Is 6505552368 invalid us telephone number? if so why? P.S I'm not from U.S
Michael Christofersen
@mchristofersen
Aug 08 2015 07:08
basically it is
but they don't want it
just change your regexp to throw out any number that ends in ')'
Azhagan
@Azhagan
Aug 08 2015 07:10
@mchristofersen thanks got it.
Michael Christofersen
@mchristofersen
Aug 08 2015 07:10
np
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 08:11
var bob = {
    firstName: "Bob",
    lastName: "Jones",
    phoneNumber: "(650) 777-7777",
    email: "bob.jones@example.com"
};

var mary = {
    firstName: 'Mary',
    lastName: 'Johnson',
    phoneNumber: '(650) 888-8888',
    email: 'mary.johnson@example.com'
};

var contacts = ['bob', 'mary'];

console.log(contacts[1].phoneNumber);
suppose to print out Mary's phone number
i thought i am declaring an array using [ ], and hten im calling on contacts[1] mary and using dot notation to get phone number
anyone?
Joshua
@ckent20
Aug 08 2015 08:24
mary is on 2?
yeah its on 1
idk
wontoan
@wontoan
Aug 08 2015 08:24
what does console.log(mary.phoneNumber) output?
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 08:28
her phonenumber.. but i need to output her phone number using the array
nvm i found an answer..
wontoan
@wontoan
Aug 08 2015 08:41
Good. In case you were wondering @ckent20, the problem was
var contacts = ['bob', 'mary'];
So console.log(contacts[1].phoneNumber); is actually
console.log('mary'.phoneNumber);
Easily fixed with var contacts = [bob, mary];
galacticfan
@galacticfan
Aug 08 2015 08:51
^ +1
Jonny Morley
@morley92
Aug 08 2015 09:00
hi guys, could anybody help me?
galacticfan
@galacticfan
Aug 08 2015 09:00
@morley92 What do you need help with?
Jonny Morley
@morley92
Aug 08 2015 09:00
one of the javascript challenges
essentially, i'd like my rock paper scissors and paper game to restart if the computer and user guesses the same

var userChoice = function(){
var choice = prompt("Do you choose rock, paper, scissors or rope?");
return choice;
}

var computerChoice = function(){
var choice = Math.random();
if (choice <= 0.25) {
choice = "rock";
} else if(choice <= 0.5) {
choice = "paper";
} else if(choice <= 0.75) {
choice = "scissors";
} else {
choice = "rope";
}
return choice;
}

var compare = function(choice1, choice2) {
if(choice1 === choice2) {
var newUserChoice = prompt("You tied! Play again... Do you choose rock, paper, scissors or rope?");
compare(newUserChoice, computerChoice());
} else if (choice1 === "rock"){
if (choice2 === "paper"){
return "paper wins";
}else {
return "rock wins";
}
} else if (choice1 === "paper"){
if (choice2 === "scissors"){
return "scissors wins";
} else if (choice2 === "rope"){
return "rope wins";
} else {
return "paper wins";
}
} else if (choice1 === "scissors"){
if (choice2 === "rock"){
return "rock wins";
} else {
return "scissors wins";
}
} else if (choice1 === "rope"){
if (choice2 === "rock"){
return "rock wins";
} else if (choice2 === "scissors"){
return "scissors wins";
} else {
return "rope wins";
}
} else {
return "Invalid user input";
}
}

compare(userChoice(), computerChoice());

oops
whats the best way to post code in here...
galacticfan
@galacticfan
Aug 08 2015 09:02
If they have the same choice, just recall the function that started the whole process
wontoan
@wontoan
Aug 08 2015 09:02
^ + 1
Jonny Morley
@morley92
Aug 08 2015 09:02
i believe that's what i've done though :(
wontoan
@wontoan
Aug 08 2015 09:03
test
enclose your code in ```
Jonny Morley
@morley92
Aug 08 2015 09:03
ahh
wontoan
@wontoan
Aug 08 2015 09:03
This message was deleted
Jonny Morley
@morley92
Aug 08 2015 09:03

```var userChoice = function(){
var choice = prompt("Do you choose rock, paper, scissors or rope?");
return choice;
}

var computerChoice = function(){
var choice = Math.random();
if (choice <= 0.25) {
choice = "rock";
} else if(choice <= 0.5) {
choice = "paper";
} else if(choice <= 0.75) {
choice = "scissors";
} else {
choice = "rope";
}
return choice;
}

var compare = function(choice1, choice2) {
if(choice1 === choice2) {
var newUserChoice = prompt("You tied! Play again... Do you choose rock, paper, scissors or rope?");
compare(newUserChoice, computerChoice());
} else if (choice1 === "rock"){
if (choice2 === "paper"){
return "paper wins";
}else {
return "rock wins";
}
} else if (choice1 === "paper"){
if (choice2 === "scissors"){
return "scissors wins";
} else if (choice2 === "rope"){
return "rope wins";
} else {
return "paper wins";
}
} else if (choice1 === "scissors"){
if (choice2 === "rock"){
return "rock wins";
} else {
return "scissors wins";
}
} else if (choice1 === "rope"){
if (choice2 === "rock"){
return "rock wins";
} else if (choice2 === "scissors"){
return "scissors wins";
} else {
return "rope wins";
}
} else {
return "Invalid user input";
}
}

compare(userChoice(), computerChoice());
```

galacticfan
@galacticfan
Aug 08 2015 09:03
This message was deleted
Jonny Morley
@morley92
Aug 08 2015 09:03
lol sorry
galacticfan
@galacticfan
Aug 08 2015 09:03
woops
var userChoice = function() {
    var choice = prompt("Do you choose rock, paper, scissors or rope?");
    return choice;
}
var computerChoice = function() {
    var choice = Math.random();
    if (choice <= 0.25) {
        choice = "rock";
    } else if (choice <= 0.5) {
        choice = "paper";
    } else if (choice <= 0.75) {
        choice = "scissors";
    } else {
        choice = "rope";
    }
    return choice;
}
var compare = function(choice1, choice2) {
    if (choice1 === choice2) {
        var newUserChoice = prompt("You tied! Play again... Do you choose rock, paper, scissors or rope?");
        compare(newUserChoice, computerChoice());
    } else if (choice1 === "rock") {
        if (choice2 === "paper") {
            return "paper wins";
        } else {
            return "rock wins";
        }
    } else if (choice1 === "paper") {
        if (choice2 === "scissors") {
            return "scissors wins";
        } else if (choice2 === "rope") {
            return "rope wins";
        } else {
            return "paper wins";
        }
    } else if (choice1 === "scissors") {
        if (choice2 === "rock") {
            return "rock wins";
        } else {
            return "scissors wins";
        }
    } else if (choice1 === "rope") {
        if (choice2 === "rock") {
            return "rock wins";
        } else if (choice2 === "scissors") {
            return "scissors wins";
        } else {
            return "rope wins";
        }
    } else {
        return "Invalid user input";
    }
}
compare(userChoice(), computerChoice());
there you go, easier to read now
Jonny Morley
@morley92
Aug 08 2015 09:04
there we go..
Marcus Eisele
@eiselems
Aug 08 2015 09:04
think you can place an endless loop around your last line
if you want to play indefinitely
galacticfan
@galacticfan
Aug 08 2015 09:05
@morley92 in your compare code, if the two equal each other you need to then write:
compare(userChoice(), computerChoice());
this will initiate the whole process again
Jonny Morley
@morley92
Aug 08 2015 09:06
you'd think so, but instead when it asks for input after an equal comparison, the next input will never yeild an output :/
galacticfan
@galacticfan
Aug 08 2015 09:11
let me have a quick look
@morley92 How come you've included rope? Just a personal touch?
Jonny Morley
@morley92
Aug 08 2015 09:13
yea, it was suggested as an extra thing to do on codeacademy
thought i'd have a go
galacticfan
@galacticfan
Aug 08 2015 09:16
I see what you mean about it just hanging
Jonny Morley
@morley92
Aug 08 2015 09:17
i imagine it's a small thing which is wrong..
Omar
@oab00
Aug 08 2015 09:20
yup it is
Marcus Eisele
@eiselems
Aug 08 2015 09:20
Mhm
I'm not sure if you're wrong at all
Omar
@oab00
Aug 08 2015 09:20
if (choice1 === choice2) {
        var newUserChoice = prompt("You tied! Play again... Do you choose rock, paper, scissors or rope?");
        compare(newUserChoice, computerChoice());
no return ?
Marcus Eisele
@eiselems
Aug 08 2015 09:20
maybe it is related to running it on codeacademy
galacticfan
@galacticfan
Aug 08 2015 09:21
no, it is the same on repl.it
oh, lol, face desk
Jonny Morley
@morley92
Aug 08 2015 09:22
dayyyyymm
cheers @oab00
Omar
@oab00
Aug 08 2015 09:22
:)
Jonny Morley
@morley92
Aug 08 2015 09:22
i still don't quite understand that though, how come the function only runs after a return statement?
Omar
@oab00
Aug 08 2015 09:23
console.log(compare(userChoice(), computerChoice())); in the last statement
Marcus Eisele
@eiselems
Aug 08 2015 09:23
think i found it
you have to return the compare
otherwise the whole result will be undefined
you're code is not running in any return statements in this case
Jonny Morley
@morley92
Aug 08 2015 09:24
thanks @eiselems , @oab00 jsut beat you to it though :P
CamperBot
@camperbot
Aug 08 2015 09:24
morley92 sends brownie points to @eiselems and @oab00 :sparkles: :thumbsup: :sparkles:
:star: 177 | @oab00 | http://www.freecodecamp.com/oab00
Marcus Eisele
@eiselems
Aug 08 2015 09:24
or at least the first called method does return nothing
Jonny Morley
@morley92
Aug 08 2015 09:26
var userChoice = function(){
    var choice = prompt("Do you choose rock, paper, scissors or rope?");
    return choice;
}

var computerChoice = function(){
    var choice2 = Math.random();
    if (choice2 <= 0.25) {
        return "rock";
    } else if(choice2 <= 0.5) {
        return "paper";
    } else if(choice2 <= 0.75) {
        return "scissors";
    } else {
        return "rope";
    }
}


var compare = function(choice1, choice2) {
    if(choice1 === choice2) {
        var newUserChoice = prompt("You tied! Play again... Do you choose rock, paper, scissors or rope?");
        return compare(newUserChoice, computerChoice());
    } else if (choice1 === "rock"){
        if (choice2 === "paper"){
            return "paper wins";
        }else {
            return "rock wins";
        }
    } else if (choice1 === "paper"){
        if (choice2 === "scissors"){
            return "scissors wins";
        } else  if (choice2 === "rope"){
            return "rope wins";
        }  else {
            return "paper wins";
        }
    } else if (choice1 === "scissors"){
        if (choice2 === "rock"){
            return "rock wins";
        } else {
            return "scissors wins";
        }
    } else if (choice1 === "rope"){
        if (choice2 === "rock"){
            return "rock wins";
        } else if (choice2 === "scissors"){
            return "scissors wins";
        } else {
            return "rope wins";
        }
    } else {
        return "Invalid user input";   
    }
}

compare(userChoice(), computerChoice());
this seems to work ok
Marcus Eisele
@eiselems
Aug 08 2015 09:27
ok, perfect ;)
Gino
@developergino
Aug 08 2015 09:28
Anyone on twitter ? Lets connect. :) My handle is @developergino
Jonny Morley
@morley92
Aug 08 2015 09:29
@eiselems managed to tie twice, i think i'm now addicted to this silly game....
Omar
@oab00
Aug 08 2015 09:31
now make a UI for it on codepen :p
Tawny Walling
@tawnytron
Aug 08 2015 09:33
Anyone have issues with Waypoint: Bootstrap Create a Button?
Jonny Morley
@morley92
Aug 08 2015 09:34
@oab00 think i'll move onto the loop stuff now :D
galacticfan
@galacticfan
Aug 08 2015 09:34
@tawnytron what's the problem?
seems to working fine on my end
Tawny Walling
@tawnytron
Aug 08 2015 09:35
<button type='btn'> Like this Photo </button>
Is what I put
Doesn't seem to be going through
galacticfan
@galacticfan
Aug 08 2015 09:35
@tawnytron type needs to equal submit
and the btn bit is the name of the css class in the bootstrap css
so you need to assign a class to the button using class='btn'
Tawny Walling
@tawnytron
Aug 08 2015 09:36
okay maybe I'm confused on how to integrate the class
galacticfan
@galacticfan
Aug 08 2015 09:36
This message was deleted
Tawny Walling
@tawnytron
Aug 08 2015 09:37
<button type='submit' class="btn"> Like this Photo </button>
galacticfan
@galacticfan
Aug 08 2015 09:37
so the end result should be similar to
<button type="submit" class="btn">My Button</button>
Tawny Walling
@tawnytron
Aug 08 2015 09:37
whew
got it
galacticfan
@galacticfan
Aug 08 2015 09:37
awesome
Tawny Walling
@tawnytron
Aug 08 2015 09:37
I was trying to integrate it with submit 'submit btn'
galacticfan
@galacticfan
Aug 08 2015 09:37
ahhh
Tawny Walling
@tawnytron
Aug 08 2015 09:37
Thank you! The migration from doing backend to frontend development has been a doozy for me :)
galacticfan
@galacticfan
Aug 08 2015 09:38
:)
Tawny Walling
@tawnytron
Aug 08 2015 09:38
Thank you!
Omar
@oab00
Aug 08 2015 09:43
@morley92 fast mockup https://jsfiddle.net/x0ss1w20/
good luck on your next challenges! :)
galacticfan
@galacticfan
Aug 08 2015 09:44
@oab00 Loving it
Jonny Morley
@morley92
Aug 08 2015 09:46
@oab00 that's awesome, thanks for that :)
pretty funky little website that is
Javed
@JayBee007
Aug 08 2015 10:03
but I cant understand what needs to be done...can some one kindly help..thanks
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:06
var bob = {
    firstName: "Bob",
    lastName: "Jones",
    phoneNumber: "(650) 777-7777",
    email: "bob.jones@example.com"
};

var mary = {
    firstName: "Mary",
    lastName: "Johnson",
    phoneNumber: "(650) 888-8888",
    email: "mary.johnson@example.com"
};

var contacts = [bob, mary];

function printPerson(person) {
    console.log(person.firstName + " " + person.lastName);
}

function list(){
    var contactsLength = [];
    for(i = 0; i < 2; i++;) {
        console.print(printPerson[i]);
    }
}

    list[i];
says syntax error
having problems also with..:04. Inside of the loop, add code to call printPerson, passing in the element of the array that the loop is currently at.
  1. At the very bottom of the file, call the list function. The list function should then loop through every member of the contacts array and print its information.
galacticfan
@galacticfan
Aug 08 2015 10:07
you need to write var before i in your for loop
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:07
which i?
galacticfan
@galacticfan
Aug 08 2015 10:08
you need to change for loop to:
for(var i = 0; i < 2; i++) {
        console.log(printPerson[i]);
}
Omar
@oab00
Aug 08 2015 10:08
"call the list function"
this list[i]; is not how you call a function
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:09
i added the var in my for loop and it still says im missing )
galacticfan
@galacticfan
Aug 08 2015 10:09
also, remove the semi-colon, sorry didn't see that
Omar
@oab00
Aug 08 2015 10:10
list() <-- this is how you call a function :)
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:10
thanks @oab00 i did that..
CamperBot
@camperbot
Aug 08 2015 10:10
dueldrawer8 sends brownie points to @oab00 :sparkles: :thumbsup: :sparkles:
:star: 178 | @oab00 | http://www.freecodecamp.com/oab00
Omar
@oab00
Aug 08 2015 10:11
np!
I'm stealing your points @galacticfan sorry :sweat_smile:
galacticfan
@galacticfan
Aug 08 2015 10:11
@oab00 haha, don't worry ;)
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:12
TypeError: Object doesn't support property or method 'print'
ty @galacticfan
wontoan
@wontoan
Aug 08 2015 10:13
This message was deleted
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:13
oh nvm
console.log..
It looks like your list function didn't console.log "Bob Jones". Did you remember to call list(); after creating it?
var bob = {
    firstName: "Bob",
    lastName: "Jones",
    phoneNumber: "(650) 777-7777",
    email: "bob.jones@example.com"
};

var mary = {
    firstName: "Mary",
    lastName: "Johnson",
    phoneNumber: "(650) 888-8888",
    email: "mary.johnson@example.com"
};

var contacts = [bob, mary];

function printPerson(person) {
    console.log(person.firstName + " " + person.lastName);
}

function list(){
    var contactsLength = [];
    for(var i = 0; i < 2; i++) {
        console.log(printPerson[i]);
    }
}

    list([i]);
Omar
@oab00
Aug 08 2015 10:15
console.log(printPerson[i]); something wrong here
galacticfan
@galacticfan
Aug 08 2015 10:16
you also need to use list(contacts)
as opposed to list([i])
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:17
i also changed i < contacts.length
wontoan
@wontoan
Aug 08 2015 10:17
Has anyone completed Bonfire #21: Roman Numeral Converter and actually used .splice, .indexOf, and .join?
Michael Christofersen
@mchristofersen
Aug 08 2015 10:18
Has anybody done Zipline: Build a random quote generator?
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:19
hmm whats wrong with console.log(printPerson[i])
says list function doesn't look like it logs bob jones.. and ask if i rembered to call the list function
Omar
@oab00
Aug 08 2015 10:23
printPerson is a function and that is not how you call a function
Optmistic
@Optmistic
Aug 08 2015 10:24
' ' '
what's wrong with this code ??
//Find the longest word in string ??
function findLongestWord(str) {
 var parts= str.split('');
  var longest=0;
  //var answer='';
  for(var i=0; i< parts.length ;i++)
    {
      //parts[i] = parts[i].replace(/[^a-zA-Z]+/g, "");
      if(parts[i].lenghth > longest)
        {
          longest= parts[i];
          //answer.length=parts[i].length;
        }
    }
   return longest; 

}

findLongestWord('The quick brown fox jumped over the lazy dog');
galacticfan
@galacticfan
Aug 08 2015 10:25
@Optmistic longest = parts[i].length
This message was deleted
Optmistic
@Optmistic
Aug 08 2015 10:26
@galacticfan again eroor
its returning lenght 0
wontoan
@wontoan
Aug 08 2015 10:27
i see a spelling error
galacticfan
@galacticfan
Aug 08 2015 10:27
split also needs to be split(' ')
function findLongestWord(str) {
 var parts = str.split(" ");
  var longest=0;
  for(var i=0; i< parts.length ;i++)
    {
      if(parts[i].length > longest)
        {
          longest= parts[i].length;
        }
    }
   return longest; 

}

findLongestWord('The quick brown fox jumped over the lazy dog');
@wontoan nice spot
Optmistic
@Optmistic
Aug 08 2015 10:29
@galacticfan not working fine :(
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:29
@oab00 04. Inside of the loop, add code to call printPerson, passing in the element of the array that the loop is currently at.
galacticfan
@galacticfan
Aug 08 2015 10:29
@Optmistic it returns a length of 6 so it is isn't it?
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:29
its asking me to call that function inside my loop..
var bob = {
    firstName: "Bob",
    lastName: "Jones",
    phoneNumber: "(650) 777-7777",
    email: "bob.jones@example.com"
};

var mary = {
    firstName: "Mary",
    lastName: "Johnson",
    phoneNumber: "(650) 888-8888",
    email: "mary.johnson@example.com"
};

var contacts = [bob, mary];

function printPerson(person) {
    console.log(person.firstName + " " + person.lastName);
}

function list(){
    var contactsLength = [contacts];
    for(var i = 0; i < contacts.length; i++) {
    console.log(contactsLength[i]);
    }
}

    list(contacts);
Optmistic
@Optmistic
Aug 08 2015 10:30
@galacticfan its returnin 0
galacticfan
@galacticfan
Aug 08 2015 10:31
@Optmistic Did you try the code I posted? There was also a spelling error that @wontoan pointed out
Optmistic
@Optmistic
Aug 08 2015 10:32
@galacticfan thankuuu its working now
:)
Omar
@oab00
Aug 08 2015 10:35
@Dueldrawer8 might I suggest clearing the list function and stick to printing one person first
how would u print bob ?
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:36
console.log(contact[0])..if i wanted to print all of his informatino
information
Omar
@oab00
Aug 08 2015 10:37
how would you print it using the function printPerson ?
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:38
printPerson(contact[0]) right?
Omar
@oab00
Aug 08 2015 10:39
correct !
now change that to be inside a for loop :p
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:40
but i want it to print both contact infos.. not just the first elements
Omar
@oab00
Aug 08 2015 10:40
so that it prints printPerson(contact[0]) first round
then prints printPerson(contact[1]) on second round
ah
sorry then you can use console.log(contact[0]) instead xD
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:42
im suppose to call the function list() and its suppose to list all of there contact info all at the same time
Omar
@oab00
Aug 08 2015 10:42
ah right so you need a for loop to loop through the contact array and console log it
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:42
well once again these are the instructions..
  1. Create a function called list that does not take any parameters.
  2. At the start of the function, define a variable to store the number of items in the contacts array. Call it contactsLength.
  3. All of the items in an array are numbered, starting at 0. To cycle through all of the elements of the array, create a for loop that cycles from 0 up to one less than the number of items in the contacts array.
  4. Inside of the loop, add code to call printPerson, passing in the element of the array that the loop is currently at.
  5. At the very bottom of the file, call the list function. The list function should then loop through every member of the contacts array and print its information.
so inside the for loop.. i do need to call the function printPerson
Omar
@oab00
Aug 08 2015 10:43
right so what you said first is correct console.log(contact[0]) you just need to stick it in a for loop
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:44
this is frustrating.. still not working
```
function printPerson(person) {
    console.log(person.firstName + " " + person.lastName);
}

function list(){
    var contactsLength = contacts;
    for(var i = 0; i < contacts.length; i++) {
    console.log(contacts[0]);
    }
}

    list(contacts);
Oops, try again. It looks like your list function didn't console.log "Bob Jones". Did you remember to call list(); after creating it?
Omar
@oab00
Aug 08 2015 10:45
so close!
how would u make the for loop print console.log(contacts[0]); first round
then console.log(contacts[1]); second round
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:46
no idea
Omar
@oab00
Aug 08 2015 10:47
hint what is i used for
CamperBot
@camperbot
Aug 08 2015 10:47
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
galacticfan
@galacticfan
Aug 08 2015 10:47
Haha @camperbot :D
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:47
as a placeholder.. first i where it starts
2nd i where it stops
third i by how much im incrementing by
Omar
@oab00
Aug 08 2015 10:48
correct i = 0 on first round
and i = 1 on second round
don't you think you can replace 0 with something inside console.log(contacts[0]);
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:49
i?
Omar
@oab00
Aug 08 2015 10:49
yep
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:49
this is the output... still wrong
firstName: 'Bob',
lastName: 'Jones',
phoneNumber: '(650) 777-7777',
email: 'bob.jones@example.com' }
{ firstName: 'Mary',
lastName: 'Johnson',
phoneNumber: '(650) 888-8888',
email: 'mary.johnson@example.com' }
{ firstName: 'Bob',
lastName: 'Jones',
phoneNumber: '(650) 777-7777',
email: 'bob.jones@example.com' }
{ firstName: 'Mary',
lastName: 'Johnson',
phoneNumber: '(650) 888-8888',
email: 'mary.johnson@example.com' }
Omar
@oab00
Aug 08 2015 10:50
what's the correct output tho ?
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:50
no idea..
Omar
@oab00
Aug 08 2015 10:50
link ?
Arnold Stoba
@arnoldstoba
Aug 08 2015 10:51
Does somebody have a second to help me with an AngularJS dependency injection problem?
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:51
nvm.. i found it lol
its on the next page
Omar
@oab00
Aug 08 2015 10:51
looks like printPerson(contacts[i]); works
galacticfan
@galacticfan
Aug 08 2015 10:52
Hey @oab00 any chance you could give me a little help?
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:52
yup.. @oab00
Omar
@oab00
Aug 08 2015 10:52
sure!
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 10:53
thanks for helping me understanding more of what i was doing though @oab00
CamperBot
@camperbot
Aug 08 2015 10:53
dueldrawer8 sends brownie points to @oab00 :sparkles: :thumbsup: :sparkles:
:star: 179 | @oab00 | http://www.freecodecamp.com/oab00
Omar
@oab00
Aug 08 2015 10:53
np ^^
galacticfan
@galacticfan
Aug 08 2015 10:53
@oab00 it's for the chunky monkey challenge
function chunk(arr, size) {
  var result = [];
  var innerArr = [];
  var counter = 1;

  for (var i = 0; i < arr.length; i++) {
    if (counter <= size) {
      innerArr.push(arr[i]);
      counter++;

      if (i+1 === arr.length) {
        result.push(innerArr);
      }
    }
    else {
      result.push(innerArr);
      innerArr = []; // clear array (the super dangerous way)
      counter = 1; // reset counter
      innerArr.push(arr[i]);
    }
  }

  return result;
}

chunk([0, 1, 2, 3, 4, 5], 2);
for some reason it
returns [ [ 0, 1 ], [ 2, 3, 4 ] ] instead of [ [ 0, 1 ], [ 2, 3 ], [ 4, 5 ] ]
but it works for the rest of the arrays that are tested
Omar
@oab00
Aug 08 2015 10:55
where did the 5 go xD
galacticfan
@galacticfan
Aug 08 2015 10:55
I'm not sure lol
wait, I know where the 5 went
wasn't getting pushed to the result as it was the end of the loop
Omar
@oab00
Aug 08 2015 10:59
changed 1 thing and it fixed it lol
galacticfan
@galacticfan
Aug 08 2015 10:59
but still get funny results:
function chunk(arr, size) {
  var result = [];
  var innerArr = [];
  var counter = 1;

  for (var i = 0; i < arr.length; i++) {
    if (counter <= size) {
      innerArr.push(arr[i]);
      counter++;

      if (i+1 === arr.length) { // if at end of loop
        result.push(innerArr);
      }
    }
    else {
      result.push(innerArr);
      innerArr = []; // clear array (the super dangerous way)
      counter = 1; // reset counter
      innerArr.push(arr[i]);

      if (i+1 === arr.length) { // if at end of loop
        result.push(innerArr);
      }
    }
  }

  return result;
}

chunk([0, 1, 2, 3, 4, 5], 2);
@oab00 oh really?
Omar
@oab00
Aug 08 2015 11:00
if (counter <= size) {
2 = 2 still passes
and puts the 3rd element in
KieronDowie
@KieronDowie
Aug 08 2015 11:00
On Bonfire: Smallest common Multiple, I'm not sure what I'm looking for. Why is the smallest common multiple of 1 and 5 60? Shouldn't it be 5?
galacticfan
@galacticfan
Aug 08 2015 11:01
@oab00 But the counter starts at 1?
Omar
@oab00
Aug 08 2015 11:02
oh right I also changed counter to start at 0 o_o
galacticfan
@galacticfan
Aug 08 2015 11:02
Haha :D
With the latest code I get: [ [ 0, 1 ], [ 2, 3, 4 ], [ 5 ] ] instead of [ [ 0, 1 ], [ 2, 3 ], [ 4, 5 ] ]
Omar
@oab00
Aug 08 2015 11:03
yay the 5 came back !
the count in the else statement leave it to 1 and it works xD
galacticfan
@galacticfan
Aug 08 2015 11:05
What do you mean leave it to 1 and it works?
Omar
@oab00
Aug 08 2015 11:05
so
var counter = 0;
...
if (counter < size) {
    ...
} else {
    ...
    counter = 1;
    ...
}
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 11:05
/*Create a search function
then call it passing "Jones"*/
function search(lastName) {
    var contactsLength = contacts.length;
    for ( i = 0; i < contactsLength; i++) {
        if(person.lastName === lastName) {
            printPerson();
        }
    }
}

search('Jones');
ReferenceError: 'person' is undefined
galacticfan
@galacticfan
Aug 08 2015 11:05
@oab00 omg it does work, but why?!?!
this is so strange
Omar
@oab00
Aug 08 2015 11:06
uhhh not sure :confused:
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 11:06
having problems with this : 04. The twist comes here: in the body of the loop, rather than printing out every single item in the array, add an if statement that checks to see if the lastName property of the object is equal to the lastName argument. Have the function run printPerson on the person if and only if the lastName property of the person matches the lastName argument.
to call a property of an object i thought you used the dot notation..
like person.lastName
Omar
@oab00
Aug 08 2015 11:10
@galacticfan now I know why it works
it's because you're doing innerArr.push(arr[i]); in the else statement
essentially doing the job that counter = 0 should do
without incrementing counter
galacticfan
@galacticfan
Aug 08 2015 11:11
of course, I need to increment the counter when I do it, because I've just added an element to the inner array, you're a genius, thanks @oab00
Omar
@oab00
Aug 08 2015 11:12
np good luck with the next one :)
@Dueldrawer8 printPerson(); is empty you should pass it something
galacticfan
@galacticfan
Aug 08 2015 11:16
@oab00 :D
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 11:17
/*Create a search function
then call it passing "Jones"*/
function search(lastName) {
    var contactsLength = contacts.length;
    for ( i = 0; i < contactsLength; i++) {
        if(contacts[i].lastName === lastName) {
            printPerson(contacts[i]);
        }
    }
}

search('Jones');
yeah i just didn't know if it was person.lastName or something else.. which it was something else
i guess since im using for loop and an array it has to be with the [i]
whenever i read thecode.. it makes perfect sense
but looking at a problem and trying to think how to do it.. hard for me to do lol
need to study or do more of these excercises
with the arrays and objects
well im off to bed.. thanks for help
Mags Prescott
@magsprescott
Aug 08 2015 11:45
guys
i need help
Waypoint: Use CSS Selectors to Style Elements
George Tsoukatos
@Gts0uk
Aug 08 2015 12:51
hey guys
has anyone done the 15 website projects on codecademy ?
Im doing them now to refresh my html/css knowledge
Clayton
@cjg040103
Aug 08 2015 13:44
hey! i'm on 'Bonfire: Repeat a string repeat a string' and i need 2 know how 2 repeat a string three times in a row. any tips?
CamperBot
@camperbot
Aug 08 2015 13:44
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Clayton
@cjg040103
Aug 08 2015 13:44
Bonfire: Repeat a string repeat a string
CamperBot
@camperbot
Aug 08 2015 13:44

:fire:Bonfire: Repeat a string repeat a string :link:

function repeat(str, num) {
  // repeat after me
  return str;
}

repeat('abc', 3);

Repeat a given string (first argument) n times (second argument). Return an empty string if n is a negative number.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

type: bf details bf links bf spoiler

Clayton
@cjg040103
Aug 08 2015 13:45
jeez camperbot is fast...
brb need 2 go 2 da bathroom
Clayton
@cjg040103
Aug 08 2015 13:52
k im back
bf details
CamperBot
@camperbot
Aug 08 2015 13:53

:fire:Bonfire: Repeat a string repeat a string :link:

function repeat(str, num) {
  // repeat after me
  return str;
}

repeat('abc', 3);
Repeat a given string (first argument) n times (second argument). Return an empty string if n is a negative number.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.
links:
Clayton
@cjg040103
Aug 08 2015 14:06
Nevermind. i got it
EASIEST BONFIRE EVER!!!
function repeat(str, num) {
  if(num > 0) {
    var a = (str + '' + str + '' + str);
  return a;
  } else {
    return '';
  }
}

repeat('abc', 3);
This message was deleted
CamperBot
@camperbot
Aug 08 2015 14:08
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Matthew Barber
@Honno
Aug 08 2015 14:13
Hey @cjg040103, a good practice is to make functions which work whatever the input, so you should really make a method for the strings to add together as many times as the user wants (with num)
ie use a for loop to reiterate dynamically to the num size
you're not going to reap the benefits of practical work like that xD
anyone help me with this?
i couldnt even start ..i literally dont knwo what to do :3
Clayton
@cjg040103
Aug 08 2015 14:24
what is ur code so far? @SarthakAdhikari
This message was deleted
hi. im trying to truncate a string . here's my code. what do i do?
function truncate(str, num) {
  var z = str.length;
  if(z > num) {
    var a = str.split(' ');
    var b = str[0];
    var d = str[1];
    var e = str[2];
    var c = (b + d + e + ' ' + '...');
    return c;
  } else {
    return str;
  }
}

truncate('A-tisket a-tasket A green and yellow basket', 11);
SarthakAdhikari
@SarthakAdhikari
Aug 08 2015 14:29
Anyone?
Clayton
@cjg040103
Aug 08 2015 14:29
@SarthakAdhikari what is ur current code?
what have u done so far?
SarthakAdhikari
@SarthakAdhikari
Aug 08 2015 14:30
here :P this code makes no sense..no sense at all
/*jshint multistr:true */

var text = "Sarthaksda"
var myName = "Sarthak"
var hits = [];

for(var i=0;i<text.length; i++) {
    if (text[i]==="S") {
        for (var j=i;j<(text.length+myName.lenght);j++){

        }
    }
}
Clayton
@cjg040103
Aug 08 2015 14:30
ya...
1 sec
SarthakAdhikari
@SarthakAdhikari
Aug 08 2015 14:31
:D
Matthew Barber
@Honno
Aug 08 2015 14:31
@SarthakAdhikari You need to check if the first letter of your name matches with any letters of the text var, then push the follow letters that construct your name into the hits var
/*jshint multistr:true */
var text = "Matt Bob Eric Eric Bob Matt Eric Bob Matt"
var myName = "Matt"
var hits = []

for (var i = 0; i < text.length; i++) {
    if (text[i] === myName[0]) {
        for (var x = i; x < (myName.length + i); x++) {
            hits.push(text[x])
        }
    }
}
Clayton
@cjg040103
Aug 08 2015 14:32
let @Honno hlp u. im lost...
does anyone have any tips 4 me?
function truncate(str, num) {
  var z = str.length;
  if(z > num) {
    var a = str.split(' ');
    var b = str[0];
    var d = str[1];
    var e = str[2];
    var c = (b + d + e + ' ' + '...');
    return c;
  } else {
    return str;
  }
}

truncate('A-tisket a-tasket A green and yellow basket', 11);
are we the only 3 people on here??
M Used
@mildused
Aug 08 2015 14:33
Nope
SarthakAdhikari
@SarthakAdhikari
Aug 08 2015 14:33
@Honno ty but this part was sooo hard
Matthew Barber
@Honno
Aug 08 2015 14:34
This message was deleted
Clayton
@cjg040103
Aug 08 2015 14:34
@mildused i hope not...
Matthew Barber
@Honno
Aug 08 2015 14:34
whoops
didn't mean to delete lol
Clayton
@cjg040103
Aug 08 2015 14:34
is ok...
Matthew Barber
@Honno
Aug 08 2015 14:34
lemme rewrite that ugh
SarthakAdhikari
@SarthakAdhikari
Aug 08 2015 14:34
JS i surrender :3
Clayton
@cjg040103
Aug 08 2015 14:34
:stuck_out_tongue_winking_eye:
Matthew Barber
@Honno
Aug 08 2015 14:35
@cjg040103 Make it so that if the length of str is larger than the num, take out the first num -3 letters of str and return it
otherwise return str on it's own
you can use the splice function to take out the first num - 3 letters
Clayton
@cjg040103
Aug 08 2015 14:35
ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
hhh
h...
Matthew Barber
@Honno
Aug 08 2015 14:36
e.g. str.slice(0, num - 3) + "..."; will return the num - 3 letters of str
Clayton
@cjg040103
Aug 08 2015 14:36
facepalm
k. thx so much! :grinning:
Matthew Barber
@Honno
Aug 08 2015 14:37
@cjg040103 just to mention, the first argument of splice is the index you want to start at, and the second argument is how many characters you want to take away
Clayton
@cjg040103
Aug 08 2015 14:38
k
@Honno I did it!
Matthew Barber
@Honno
Aug 08 2015 14:42
@cjg040103 grats!
galacticfan
@galacticfan
Aug 08 2015 14:42
Hey @cjg040103
Clayton
@cjg040103
Aug 08 2015 14:43
@galacticfan Hi! :smile:
galacticfan
@galacticfan
Aug 08 2015 14:44
@cjg040103 Thanks for the follow btw ;)
Clayton
@cjg040103
Aug 08 2015 14:44
ur welcome! how ya doin'?
galacticfan
@galacticfan
Aug 08 2015 14:45
Not too bad, back to attempting some more bonfire stuff, what about you?
CamperBot
@camperbot
Aug 08 2015 14:45
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Clayton
@cjg040103
Aug 08 2015 14:45
bonfire seems 2 be getting easier...
CamperBot
@camperbot
Aug 08 2015 14:45
Sorry, can't find a bonfire called seems 2 be getting easier. [ Check the map? ]
galacticfan
@galacticfan
Aug 08 2015 14:46
Which one are you on?
Clayton
@cjg040103
Aug 08 2015 14:46
i'm on the Bonfire: Chunky Monkey
CamperBot
@camperbot
Aug 08 2015 14:46
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Clayton
@cjg040103
Aug 08 2015 14:46
Bonfire: Chunky Monkey
CamperBot
@camperbot
Aug 08 2015 14:46

: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.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

type: bf details bf links bf spoiler

galacticfan
@galacticfan
Aug 08 2015 14:47
Just finished that one this morning!
Clayton
@cjg040103
Aug 08 2015 14:47
This message was deleted
@galacticfan ya did? awesome! :smile:
galacticfan
@galacticfan
Aug 08 2015 14:47
@cjg040103 had the tiniest of mistakes in it and that slowed me for ages
justindobbs
@justindobbs
Aug 08 2015 14:48
anyone know how you would hide an api key in a codepen pen? or if you can?
Clayton
@cjg040103
Aug 08 2015 14:48
@galacticfan i've been there...
@justindobbs nooooo idea
finally found a profile pic that is small enough!
This message was deleted
my dad is kicking me off da computer. gotta go... by! :smile:
galacticfan
@galacticfan
Aug 08 2015 14:51
@cjg040103 in a bit!
kian
@meecoder
Aug 08 2015 14:55
hey! i'm doing the first zipline (the random quote generator) - should I just use the same quotes as in the example?
M Used
@mildused
Aug 08 2015 15:00
@meecoder Not necessarily
Marc Davenport
@oneate7
Aug 08 2015 15:16
@meecoder You can use whatever quotes you want!
Matthew Barber
@Honno
Aug 08 2015 15:33
var Person = function(firstAndLast) {
  this.FullName = firstAndLast;
  this.setFullName = function(firstAndLast) {
    this.FullName = firstAndLast;
  };
  this.setFirstName = function(first) {
    this.FirstName = first;
  };
  this.setLastlName = function(last) {
    this.LastName = last;
  };
  this.getFullName = function() {
    return FullName;
  };
  this.getFirstName = function() {
    return FirstName;
  };
  this.getLastName = function() {
    return LastName;
  };

};
I get the error FullName isn't defined- why?
Chocobowings
@chocobowings
Aug 08 2015 15:35

The way you are using

this.

doesn't define the variable

Matthew Barber
@Honno
Aug 08 2015 15:36
ho
this taskis a bit unclear lol
I wish it showed you the tests it'll do
but I keep on getting errors and can't actually see em
Chocobowings
@chocobowings
Aug 08 2015 15:37
@Honno What is the name of the task ?
Matthew Barber
@Honno
Aug 08 2015 15:37
bonfire make a person
CamperBot
@camperbot
Aug 08 2015 15:37
Sorry, can't find a bonfire called make a person. [ Check the map? ]
Chocobowings
@chocobowings
Aug 08 2015 15:38
@Honno You should extract the first and last name from "firstAndLast" and assign them to a variable each
Matthew Barber
@Honno
Aug 08 2015 15:39
@chocobowings ah thanks, bit unclear
Chocobowings
@chocobowings
Aug 08 2015 15:39
example:
var firstName = "";
var lastName = "";
Dan Stockham
@DanStockham
Aug 08 2015 15:39
I was wondering if there is a more elegant way of writing this piece of code? It was from the "Finders Keepers" bonfire:
function find(arr, func) {
  var num;
  var boo = arr.some(func);

  if(boo === true) {

    for(var i = 0; i < arr.length; i++) {
      num = arr[i];
      if(func(num) === true) {
        return num;
       }

    }

  }
}

find([1, 2, 3, 4], function(num){ return num % 2 === 0; });
Matthew Barber
@Honno
Aug 08 2015 15:41
@DanStockham
function find(arr, func) {
  for(i = 0; i < arr.length; i++) {
    if(func(arr[i])) {
      var element = arr[i];
      break;
    }
  }
  return element;
}
not sure if I should use break like that, seems like it's ineffecient or dangerous heh
elegant wise you've got it really, I didn't use some then
Dan Stockham
@DanStockham
Aug 08 2015 15:42
Alright, it just seems like .some() is pretty useless.
If I am testing func using a conditional, then boo is like the third wheel.
Lightwaves
@Lightwaves
Aug 08 2015 15:43
Eh it's not completely useless it's like a for loop with a if (condition) break
Matthew Barber
@Honno
Aug 08 2015 15:43
yeah some is more pretty
I just couldn't understand it at the time so made something else lol
Lightwaves
@Lightwaves
Aug 08 2015 15:45
pretty much what hono did is what some does
DTing
@dting
Aug 08 2015 15:46
@DanStockham you can use some there like this:
function find(arr, func) {
  var num;
  arr.some(function(e) {
    if (func(e)) {
      num = e;
      return true;
    }
  });
  return num;
}
some is like a forEach but you can exit early by returning true.
Lightwaves
@Lightwaves
Aug 08 2015 15:47
I was just going to post something like that dting xD
Dan Stockham
@DanStockham
Aug 08 2015 15:47
@dting Man, I forgot using truesy values.
M Used
@mildused
Aug 08 2015 15:47
@dting or break a for each loop?
DTing
@dting
Aug 08 2015 15:47
@mildused well i would just return from a for loop.
M Used
@mildused
Aug 08 2015 15:48
@dting I saw that out of context, proceed haha
DTing
@dting
Aug 08 2015 15:49
@mildused haha
function find(arr, func) {
  for (var i = 0; i < arr.length; i++) {
    if (func(arr[i])) return arr[i];
  }
}
kdevitto
@kdevitto
Aug 08 2015 15:52
Could somebody please look at my code and show me where I went wrong? Thanks
Chocobowings
@chocobowings
Aug 08 2015 15:53
@kdevitto Where is you code ? :)
kdevitto
@kdevitto
Aug 08 2015 15:55
Should I post the whole thing here?
Chocobowings
@chocobowings
Aug 08 2015 15:55
@kdevitto Yes or send me PM
Shaklin
@ShaklinSyed
Aug 08 2015 15:56
@kdevitto yes and wrap the code around ```
kdevitto
@kdevitto
Aug 08 2015 15:56

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

<style>
h2 {
font-family: Lobster, Monospace;
}

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

<div class='row'>
<div class='col-xs-8'>
<h2 class='text-primary text-center'>CatPhotoApp</h2>
</div>
<div class='col-xs-4'>
<a href='#'><img class='img-responsive thick-green-border' src='https://bit.ly/fcc-kittens'/></a>
</div>
</div>
<br>
<img src='http://bit.ly/fcc-kittens2' class='img-responsive'>
<br>

<div class='row'>
<div class=col-xs-6>
<button class='btn btn-block btn-primary'><i class='fa fa-thumbs-up'></i> Like</button>
</div>
<div class=col-xs-6>
<button class='btn btn-block btn-info'><i class='fa fa-info-circle'></i> Info</button>
</div>
<div class=col-xs-6>
<button class='btn btn-block btn-danger'><i class='fa fa-trash'></i> Delete</button>
</div>
</div>

<p>Things cats love:</p>

<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>

<p>Top 3 things cats hate:</p>

<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>

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

Chocobowings
@chocobowings
Aug 08 2015 15:57
@kdevitto
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<style>
h2 {
font-family: Lobster, Monospace;
}

.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}
</style>
<div class='row'>
<div class='col-xs-8'>
<h2 class='text-primary text-center'>CatPhotoApp</h2>
</div>
<div class='col-xs-4'>
<a href='#'><img class='img-responsive thick-green-border' src='https://bit.ly/fcc-kittens'/></a>
</div>
</div>
<br>
<img src='http://bit.ly/fcc-kittens2' class='img-responsive'>
<br>
<div class='row'>
<div class=col-xs-6>
<button class='btn btn-block btn-primary'><i class='fa fa-thumbs-up'></i> Like</button>
</div>
<div class=col-xs-6>
<button class='btn btn-block btn-info'><i class='fa fa-info-circle'></i> Info</button>
</div>
<div class=col-xs-6>
<button class='btn btn-block btn-danger'><i class='fa fa-trash'></i> Delete</button>
</div>
</div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
<form action="/submit-cat-photo">
<label><input type='radio' name='indoor-outdoor'> Indoor</label>
<label><input type='radio' name='indoor-outdoor'> Outdoor</label>
<br>
<label><input type='checkbox' name='personality'> Loving</label>
<label><input type='checkbox' name='personality'> Lazy</label>
<label><input type='checkbox' name='personality'> Crazy</label>
<br>
<input type='text' placeholder='cat photo URL' required>
<button type='submit'>Submit</button>
</form>
Dan Stockham
@DanStockham
Aug 08 2015 15:58
lunch time brb
kdevitto
@kdevitto
Aug 08 2015 15:59
Yeah, What is wrong with it?
Valerie M
@SerenityFL
Aug 08 2015 16:00
Is this just for when you are further advanced, or can we get help here for a beginning lesson as well?
Chocobowings
@chocobowings
Aug 08 2015 16:00
@kdevitto Can you send me a link to the problem ?
@SerenityFL Any kind of help that you need
Shaklin
@ShaklinSyed
Aug 08 2015 16:01
need some help understanding bonfire Arguments Optional
Chocobowings
@chocobowings
Aug 08 2015 16:02
@ShaklinSyed you need to use closures
Shaklin
@ShaklinSyed
Aug 08 2015 16:03
could you please elobarate @chocobowings like the problem
so from what i understand it asks us to return the sum if we have two arguments
i find difficulty in understanding what i should be doing if i get only one argument
kdevitto
@kdevitto
Aug 08 2015 16:04
@chocobowings I have pmed you
Shaklin
@ShaklinSyed
Aug 08 2015 16:05
function add() {
  if(arguments.length === 2){
      return arguments[0]+arguments[1];
  }
  else{
   //what should i do here
  }
}

add(2,3);
Chocobowings
@chocobowings
Aug 08 2015 16:07
This message was deleted
This message was deleted
Shaklin
@ShaklinSyed
Aug 08 2015 16:08
yes
Chocobowings
@chocobowings
Aug 08 2015 16:09
@ShaklinSyed
else {
return function r(x)
        {
"do something with x"
       }

}
Luis Felipe López G.
@luishendrix92
Aug 08 2015 16:12
@ShaklinSyed Don't forget to check if the arguments are number or not because one of the tests checks to see if ([3]) + (2) is undefined because [3] is an object/array and not a number and javaScript will try to convert the [3] to a number and thus returning 5 as expected (but FCC expects that operation to be undefined.
Also, return a function that sums the x of the OUTER function and the first argument of THAT function.
Shaklin
@ShaklinSyed
Aug 08 2015 16:13
@luishendrix92 the intermediate part is what i dont understand
i did check if the type of argument was number or not
but need help with understanding what should i do if i get only one argumetn
like call which method>/
?
Feners4
@Feners4
Aug 08 2015 16:15
can someone help me out with why my err-src wont work when its supposed to in the event that an article picture is not available?http://codepen.io/Feners4/pen/XbOxoa
Luis Felipe López G.
@luishendrix92
Aug 08 2015 16:15
@ShaklinSyed in the IF statement, put the returned ANONYMOUS function inside ELSE. and inside that anonymous function you should return the sum of x and the first argument of the anonymous function. (remember closures)
Also have in consideration that you also have to check if the argument in the inner function is a number or not.
Valerie M
@SerenityFL
Aug 08 2015 16:15
I have a question about CSS. I've never created one, just edited. So I do not understand this .red-text business. Anyone can help?
Chocobowings
@chocobowings
Aug 08 2015 16:16
@SerenityFL .red-text is a class name
Valerie M
@SerenityFL
Aug 08 2015 16:17
@chocobowings right, but I've never seen that, so I'm having a hard time figuring out where to put it so that it's done correctly. I can change the heading to red easy, but the .red-text and where it goes ...???
Chocobowings
@chocobowings
Aug 08 2015 16:17
@SerenityFL
<style>
.red-text 
{"do somtehing"}
</style>

html
<div class=".red-text">
</div>
Optmistic
@Optmistic
Aug 08 2015 16:17
please guide me how i do it .
//Title Case a Sentence
function titleCase(str) {

  return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();

}

titleCase("I'm 
a little tea pot");
Valerie M
@SerenityFL
Aug 08 2015 16:18
How do you add a pic here?
minakasiin
@minakasiin
Aug 08 2015 16:18
in your HTML code you need to name Div to "red-text" and in CSS you can add properties to it - like color, size, position, etc.
Optmistic
@Optmistic
Aug 08 2015 16:18
@SerenityFL which pic
Valerie M
@SerenityFL
Aug 08 2015 16:18
I want to show what I'm looking at.
Luis Felipe López G.
@luishendrix92
Aug 08 2015 16:19
@Optmistic What you are doing there is applying the procedure you need to the WHOLE string! You need to do that with each word of the string and you can do that two ways... using the String.prototype.split() method or the String.prototype.match() method (which takes a regex or a string as a parameter)
Chocobowings
@chocobowings
Aug 08 2015 16:19
@SerenityFL check markdown help below where the chat icon is
Joe
@reitmanj
Aug 08 2015 16:19
Hi. Has anyone completed Bonfire: Inventory Update?
Valerie M
@SerenityFL
Aug 08 2015 16:19
@chocobowings Oh, okay, I thought that meant you marked someone's help as not good, so didn't want to click it. Pic coming to show what I'm looking at.
Luis Felipe López G.
@luishendrix92
Aug 08 2015 16:20
You can also do research on String.prototype.replace()
Optmistic
@Optmistic
Aug 08 2015 16:20
in my code what can i add more ??
Valerie M
@SerenityFL
Aug 08 2015 16:23
This is what I'm looking at: I can change the color to red, but I don't have a clue where to put the .red-text alt
Chocobowings
@chocobowings
Aug 08 2015 16:24
@SerenityFL if you need to add it to your h2 element
<h2 class='red-text'>
</h2>
@SerenityFL
css
.red-text
{
}
Valerie M
@SerenityFL
Aug 08 2015 16:25
Instructions say to do this: Instead of creating a new style element, try removing the h2 style declaration from your existing style element, then replace it with the class declaration for ".red-text". It sounded to me like they didn't want me to put in an html element
Luis Felipe López G.
@luishendrix92
Aug 08 2015 16:25

@Optmistic Have this pseudocode in mind and use the tools I gave you:

Grab every word inside the string and store it in an array. (using match or split).
To each of the words do this: Replace the first character with its uppercase equivalent and add the rest of the word to it. (you did it right using split, charAt() and toUpperCase there but the .toLowerCase at the end should not be there).
Join the array and return it as a string.

You can do this by using a for-loop or the String.prototype.replace() along with String.prototype.match()

Chocobowings
@chocobowings
Aug 08 2015 16:26

@SerenityFL is asking you to remove

h2 
{}

from your css code and add a .red-text

Valerie M
@SerenityFL
Aug 08 2015 16:27
@chocobowings I did that. Still said it was not done. It keeps telling me I have to put in the .red-text and I've tried all over it and cannot figure out where that goes
Chocobowings
@chocobowings
Aug 08 2015 16:27
@SerenityFL can you paste your code here or send me a PM
Dan Stockham
@DanStockham
Aug 08 2015 16:30
alright back for round 2
Dan Stockham
@DanStockham
Aug 08 2015 16:45
I'm only returning 1 and 3 from the loop:
function drop(arr, func) {
  var num;
  for( var i = 0; i < arr.length; i++) {
    num = arr[i];
    console.log(num); //only returning 1 and 3
    if(func(arguments[num])) {


    } else {
      arr.shift();

    }

  }

  return arr;

}

drop([1, 2, 3], function(n) {return n > 0; });
Feners4
@Feners4
Aug 08 2015 16:51
can someone help me with why my err-src image is not working in codepen.io/Feners4/pen/XbOxoa
Juan Martínez
@jbmartinez
Aug 08 2015 16:56
@DanStockham you have an array in arguments[0] and a function in arguments[1]
@Feners4 Hey!
BoomTheFace
@BoomTheFace
Aug 08 2015 16:57
@DanStockham is that bonfire 34?
Dan Stockham
@DanStockham
Aug 08 2015 16:57
@BoomTheFace Yes
Kushan Simeon
@ksimgit
Aug 08 2015 16:57
Anyone doing the jQuery waypoints on Codecademy? I need some help with jQuery Functions and Selectors Section 8.
Feners4
@Feners4
Aug 08 2015 16:57
@jbmartinez heyy!
Brian Daub
@briandaub
Aug 08 2015 16:58
Anyone willing to help on bonfire Largest Numbers Array?
BoomTheFace
@BoomTheFace
Aug 08 2015 16:58
@DanStockham Cool... so you finished 33? can you explain to me how arr.some() is supposed to be useful in that one?
@DanStockham I was planning on spending the next couple of hours on bonfires if you want to pair up
Kushan Simeon
@ksimgit
Aug 08 2015 16:59
This message was deleted
Dan Stockham
@DanStockham
Aug 08 2015 16:59
@BoomTheFace Let me finish this one I am on, and I'll help you with finders keepers
Kushan Simeon
@ksimgit
Aug 08 2015 16:59
'''
$('document').ready(function(){
$('.red,.pink').fadeTo('slow',0);
});
'''
BoomTheFace
@BoomTheFace
Aug 08 2015 16:59
@DanStockham fair enouh
Dan Stockham
@DanStockham
Aug 08 2015 16:59
@jbmartinez Right, but I'm running the arguments through func()
Luis Felipe López G.
@luishendrix92
Aug 08 2015 17:00
@BoomTheFace What you need help with? Start in knowing that you may need two loops
BoomTheFace
@BoomTheFace
Aug 08 2015 17:00
@luishendrix92 I think I can do it with one, but I don't know why they are suggesting arr.some(). Seems superfluous.
Chocobowings
@chocobowings
Aug 08 2015 17:01
Anybody working on Bonfire: Exact Change ?
CamperBot
@camperbot
Aug 08 2015 17:01
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Clayton
@cjg040103
Aug 08 2015 17:01
hey guys... i'm working on "Bonfire: Chunky Monkey" and i am completely lost... where should i start?
Dan Stockham
@DanStockham
Aug 08 2015 17:01
bonfire Drop it
CamperBot
@camperbot
Aug 08 2015 17:01

:fire:Bonfire: Drop it :link:

function drop(arr, func) {
  // Drop them elements.
  return arr;
}

drop([1, 2, 3], function(n) {return n < 3; });

Drop the elements of an array (first argument), starting from the front, until the predicate (second argument) returns true.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

type: bf details bf links bf spoiler

BoomTheFace
@BoomTheFace
Aug 08 2015 17:01
well thats neat
Dan Stockham
@DanStockham
Aug 08 2015 17:01
bf details
CamperBot
@camperbot
Aug 08 2015 17:01

:fire:Bonfire: Drop it :link:

function drop(arr, func) {
  // Drop them elements.
  return arr;
}

drop([1, 2, 3], function(n) {return n < 3; });
Drop the elements of an array (first argument), starting from the front, until the predicate (second argument) returns true.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.
links:
Feners4
@Feners4
Aug 08 2015 17:01
@jbmartinez mind checking out my code to see why my err-src for the profile picture isnt working?
Dan Stockham
@DanStockham
Aug 08 2015 17:02
bf links
Clayton
@cjg040103
Aug 08 2015 17:02
camperbot can be really annoying...
CamperBot
@camperbot
Aug 08 2015 17:02
Clayton
@cjg040103
Aug 08 2015 17:02
sometimes...
Dan Stockham
@DanStockham
Aug 08 2015 17:02
Sorry, I will refrain.
Luis Felipe López G.
@luishendrix92
Aug 08 2015 17:02
@BoomTheFace Some is in ES5.1 and it's not very compatible with older browsers.
Clayton
@cjg040103
Aug 08 2015 17:02
oh no, thats not what i meant @DanStockham
Juan Martínez
@jbmartinez
Aug 08 2015 17:03
@DanStockham why do you use arguments if you already has the array in a parameter?
Luis Felipe López G.
@luishendrix92
Aug 08 2015 17:03
You can also get around with array.filter or array.map/reduce
BoomTheFace
@BoomTheFace
Aug 08 2015 17:03
@luishendrix92 I guess my point is I can just loop through the array and find where the function returns true and return that element... I'm not sure why I would need some.
Juan Martínez
@jbmartinez
Aug 08 2015 17:03
@Feners4 I'm on it
Dan Stockham
@DanStockham
Aug 08 2015 17:04
@jbmartinez I guess you have a point.
BoomTheFace
@BoomTheFace
Aug 08 2015 17:04
@luishendrix92 I figure they were suggesting it for a reason, just couldn't firgure out why.
Luis Felipe López G.
@luishendrix92
Aug 08 2015 17:04
@BoomTheFace And my point is that you are using indeed two loops or iterative methods: One to loop through the array of arrays and the other to look inside each of the element inside those arrays.
Clayton
@cjg040103
Aug 08 2015 17:04
i meant camperbot can be annoying when ur not actively trying to trigger him, like when u need help with a bonfire and u post the name of it for everyone to look it up.
CamperBot
@camperbot
Aug 08 2015 17:04
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Clayton
@cjg040103
Aug 08 2015 17:05
SEE?!?
BoomTheFace
@BoomTheFace
Aug 08 2015 17:05
@cjg040103 lol
Clayton
@cjg040103
Aug 08 2015 17:05
he needs work...
bad
Dan Stockham
@DanStockham
Aug 08 2015 17:06
@cjg040103 he needs his batteries taken out.
Clayton
@cjg040103
Aug 08 2015 17:06
@DanStockham THANK YOU!!!!!!
Dan Stockham
@DanStockham
Aug 08 2015 17:06
camperbot shut down.
Clayton
@cjg040103
Aug 08 2015 17:06
if only...
BoomTheFace
@BoomTheFace
Aug 08 2015 17:07
@luishendrix92 are we talking about the same bf? there is only one array in 33. Two arguments, one array, and one function.
Luis Felipe López G.
@luishendrix92
Aug 08 2015 17:07
I was thinking of
bf largest of four
CamperBot
@camperbot
Aug 08 2015 17:07
Sorry, can't find a bonfire called largest of four. [ Check the map? ]
BoomTheFace
@BoomTheFace
Aug 08 2015 17:08
@luishendrix92 ah.. I'm talking about Finders Keepers.
bf finders keepers
CamperBot
@camperbot
Aug 08 2015 17:08

:fire:Bonfire: Finders Keepers :link:

function find(arr, func) {
  var num = 0;
  return num;
}

find([1, 2, 3, 4], function(num){ return num % 2 === 0; });

Create a function that looks through an array (first argument) and returns the first element in the array that passes a truth test (second argument).
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

type: bf details bf links bf spoiler

BoomTheFace
@BoomTheFace
Aug 08 2015 17:08
ehhehe
Joe
@reitmanj
Aug 08 2015 17:08
@chocobowings I'm stuck on that. In a bad way.
Luis Felipe López G.
@luishendrix92
Aug 08 2015 17:09
@BoomTheFace Ok I'll look into that, SOME seems the appropiate way of doing it since it returns a boolean.
BoomTheFace
@BoomTheFace
Aug 08 2015 17:09
@luishendrix92 but it wants the element... not a boolean
@luishendrix92 like I said, seems superfluous.
Clayton
@cjg040103
Aug 08 2015 17:10
"'if only, if only,' the woodpecker sighs, 'the bark on the tree were as soft as the skies!'. The wolf waits below, hungry and lonely. He cries to the moon! 'If only, if only...'". The book was way better than the movie...
Juan Martínez
@jbmartinez
Aug 08 2015 17:12
@Feners4 err-src is being populated, but it's value is not being copied to src. I'm looking into that now
Clayton
@cjg040103
Aug 08 2015 17:13
bye 4 now.
Feners4
@Feners4
Aug 08 2015 17:15
@jbmartinez ahhh
BoomTheFace
@BoomTheFace
Aug 08 2015 17:16
Lunch break time. Have fun all.
Azhagan
@Azhagan
Aug 08 2015 17:24
Bonfire: Symmetric difference. Any Idea how to solve anyone?
CamperBot
@camperbot
Aug 08 2015 17:24
Sorry, can't find a bonfire called symmetric difference any idea how to solve anyone. [ Check the map? ]
Sean Campbell
@natac13
Aug 08 2015 17:26
@Azhagan Umm no I am on the same one
@Azhagan I don't understand why it wants to see a number which appears in all the input arrays in the solution
Juan Martínez
@jbmartinez
Aug 08 2015 17:28
@Feners4 I guess the problem is in the $watch function
David Hewitt
@davidmhewitt
Aug 08 2015 17:28
@Azhagan @natac13 I've solved that one, you can solve it using recursion and your solution to beginner bonfire 8
DTing
@dting
Aug 08 2015 17:28
@natac13 @Azhagan think of it as sym(sym(a, b), c)
rather than sym(a,b,c)
David Hewitt
@davidmhewitt
Aug 08 2015 17:30
@dting @Azhagan @natac13 Yes, also make sure that you keep in mind that everything should be a set (as in, there can be no duplicates). So remove the duplicates from your inputs and outputs to make things easier.
DTing
@dting
Aug 08 2015 17:30
@davidmhewitt you can use reduce instead of recursion also.
Azhagan
@Azhagan
Aug 08 2015 17:30
@dting How exactly to use reduce() I'm confused.
David Hewitt
@davidmhewitt
Aug 08 2015 17:32
@dting As always, there are multiple ways to solve a problem :smile: Recursion seemed elegant as like you said, it can be seen as sym(sym(a, b), c)
Matthew Barber
@Honno
Aug 08 2015 17:35
Could someone show me their solution to bonfire: make a person? I don't get it lol
the errors are silly, like one variable needs to be global apparently, even tho that's bad practice?
Would just like to see what's going on heh
Randy Goldsmith
@Dueldrawer8
Aug 08 2015 17:36
function add(firstName, lastName, email, phoneNumber) {
    contacts[contact.length] = {
        firstName: firstName,
        lastName: lastName,
        phoneNumber: phoneNumber,
        email: email
    };
}
DTing
@dting
Aug 08 2015 17:37

@Azhagan reduce prevents you from having to use recursion. It is short hand for:

var result = [];
for (...) {
   // do something with result;
}
return result;

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce

Randy Goldsmith
@Dueldrawer8
Aug 08 2015 17:37
  1. In this new function, you want to create a new contact object like bob and mary. Instead of having this object's property values be filled with strings though, set them to the appropriate function parameters passed in.
  2. Add this new contact object to the contacts array.
how do i do those two directions?
David Hewitt
@davidmhewitt
Aug 08 2015 17:37

@Honno ```
var Person = function(fullName) {

this.getFirstName = function() {
  return first;
};

this.getLastName = function() {
  return last;
};

this.getFullName = function() {
  return firstAndLast;
};

this.setFirstName = function(newFirst) {
  first = newFirst;
};

this.setLastName = function(newLast) {
  last = newLast;
};

this.setFullName = function(newFull) {
  firstAndLast = newFull;
  first = firstAndLast.split(" ")[0];
  last = firstAndLast.split(" ")[1];
};

var firstAndLast = fullName;
var first = firstAndLast.split(" ")[0];
var last = firstAndLast.split(" ")[1];

};
```

Matthew Barber
@Honno
Aug 08 2015 17:38
thanks @davidmhewitt
CamperBot
@camperbot
Aug 08 2015 17:38
honno sends brownie points to @davidmhewitt :sparkles: :thumbsup: :sparkles:
:star: 1 | @davidmhewitt | http://www.freecodecamp.com/davidmhewitt
David Hewitt
@davidmhewitt
Aug 08 2015 17:38
@Honno Whoops, not sure why the backticks didn't work properly there, guess they had to be on a new line.
Matthew Barber
@Honno
Aug 08 2015 17:38
haha yea weird
David Hewitt
@davidmhewitt
Aug 08 2015 17:39
@Honno But yes, none of the variables are global because you don't put a this in front of them. So the only things accessible from outside the class are the methods.
Feners4
@Feners4
Aug 08 2015 17:39
@jbmartinez should I switch it to observe?
Matthew Barber
@Honno
Aug 08 2015 17:39
@davidmhewitt Mhm, it's just redundant asking for a function to get those values, and then assigning them to a global var anyway heh
Feners4
@Feners4
Aug 08 2015 17:40
@jbmartinez even with $observe it doesnt work..
Azhagan
@Azhagan
Aug 08 2015 17:40
@dting Yeah I know reduce function. Any idea How to use reduce() for Bonfire: symmetric difference
DTing
@dting
Aug 08 2015 17:41
@Azhagan write a function that will give you the symmetric difference of 2 arrays. Then use that function as the callback to reduce.
Juan Martínez
@jbmartinez
Aug 08 2015 17:41
@Feners4 I was trying observe and didn't work, but I think observe is the way
Mark Dang
@dangm24
Aug 08 2015 17:43
Hey all, can anybody clarify something for me on Bonfire: Convert HTML Entities
CamperBot
@camperbot
Aug 08 2015 17:43
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Mark Dang
@dangm24
Aug 08 2015 17:44
bonfire Convert HTML Entities
CamperBot
@camperbot
Aug 08 2015 17:44

:fire:Bonfire: Convert HTML Entities :link:

function convert(str) {
  // &colon;&rpar;
  return str;
}

convert('Dolce & Gabbana');

Convert the characters "&", "<", ">", '"' (double quote), and "'" (apostrophe), in a string to their corresponding HTML entities.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

type: bf details bf links bf spoiler

Luis Felipe López G.
@luishendrix92
Aug 08 2015 17:50

Came up with this to solve Finders Keepers:

function find(arr, func) {
  var result;
  if (arr.some(function(number) {result = number;return func(number);}))
    return result;
  else
    return;
}

find([1, 2, 3, 4], function(num){ return num % 2 === 0; });

I seriously tried to use the closure inside the paramenter but I had to create a separate function inside arr.some and pass the function in the parameter as the test to return TRUE or FALSE.

Matthew Barber
@Honno
Aug 08 2015 17:57
@davidmhewitt I use .prototype to store the methods so I couldn't bypass the test because it's stupid and checks if objects.keys(new obj) is 6, so I just copied yours in the end lol
Feners4
@Feners4
Aug 08 2015 17:58
@jbmartinez im stumped with this..
Chocobowings
@chocobowings
Aug 08 2015 18:00
i am stuck in bonfire exact change :S
CamperBot
@camperbot
Aug 08 2015 18:00
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Marc Davenport
@oneate7
Aug 08 2015 18:03
@chocobowings - What are you stuck on?
Javier Madrid
@jamc92
Aug 08 2015 18:04
Hi Campers! I'm wondering if someone here could explain to me the difference between synchronous and asynchronous? I know MongoDB is synchronous and Node.js is asynchronous but, what does that really mean? I'm lost!
Chocobowings
@chocobowings
Aug 08 2015 18:05
I can't seem to pinpoint a way to solve it without spaghetti together a bunch of if else statements ... any hint on how i go about solving this ?
Marc Davenport
@oneate7
Aug 08 2015 18:06
I have, I think, three if statements in mine.
My basic process was this:
  1. Calculate the total change required
Juan Martínez
@jbmartinez
Aug 08 2015 18:06
@Feners4 I've never used directives that way, I think you have to use the $compile method
Raincode
@Raincode
Aug 08 2015 18:07
@luishendrix92 What's wrong with this?
function find(arr, func) {
  var num = undefined;
  for (var key in arr)
    if (func(arr[key])) {
      num = arr[key];
      break;
    }
  return num;
}
Marc Davenport
@oneate7
Aug 08 2015 18:07
  1. If the change is more than what's in the drawer, insufficient. If it's the same, closed.
Chocobowings
@chocobowings
Aug 08 2015 18:07
@oneate7 up to that i am ok
Dan Stockham
@DanStockham
Aug 08 2015 18:08
So this is what I have so far:
function drop(arr, func) {
  var num;
  for( var i = 0; i <= arr.length; i++) {
    console.log(func(arguments.length));
    if(func(i) === false) {
      arr.shift();

    } else {


    }

  }

  return arr;

}

drop([1, 2, 3], function(n) {return n > 5; });
Marc Davenport
@oneate7
Aug 08 2015 18:09
After that, I basically used a do loop nested in a for loop to subtract the largest bill from the change total until the remaining change was less than the current bill or the drawer was out of that bill. The for loop moves through the bills in reverse order, the do loop does the subtraction from the change total as well as the drawer.
Juan Martínez
@jbmartinez
Aug 08 2015 18:09
@Feners4 I used a different code in my solution, but it's not very elegant: ng-src='{{item.image || item.author.picture}}'
Marc Davenport
@oneate7
Aug 08 2015 18:09
@chocobowings Did that make any sense? lol
M Used
@mildused
Aug 08 2015 18:09

Spoiler Alert

function drop(arr, func) {
 return arr.filter(func);
}

Spoiler Alert

Luis Felipe López G.
@luishendrix92
Aug 08 2015 18:10
@Raincode First of all, just declaring the variable initializes it as "undefined" so leave it as var num;
Second, you are breaking the function using break after your test in the IF statement returns true, and it never gets to return your "num"
This message was deleted
Chocobowings
@chocobowings
Aug 08 2015 18:10
@oneate7 yes it makes sense. I will try your approach to see if i can solve it. Thanks ! :)
Marc Davenport
@oneate7
Aug 08 2015 18:11
No problem... good luck!
Raincode
@Raincode
Aug 08 2015 18:11
@luishendrix92 Doesn't brake just exist the inner-most loop or switch-statement?
*exit
Luis Felipe López G.
@luishendrix92
Aug 08 2015 18:13
@Raincode Ohh I see, let me open the console.
Raincode
@Raincode
Aug 08 2015 18:15
@luishendrix92 Quoting MDN: "The break statement terminates the current loop, switch, or label statement and transfers program control to the statement following the terminated statement."
Luis Felipe López G.
@luishendrix92
Aug 08 2015 18:15
@Raincode It is working... can'tsee what you did wrong (if your bonfire tests fail)
Raincode
@Raincode
Aug 08 2015 18:16
By saying "What is wrong with this" I didn't inted to say it actualy is not working, I was implying the question why the solution with arr.some would be better or clearer
I guess it was my mistake, since I did that in the help section, sorry.
Luis Felipe López G.
@luishendrix92
Aug 08 2015 18:16
Your code makes sense and it's more readable than arr.some for those who don't know what "some" is.
I really wanted not to use Arr.some but I went with it anyway.
Raincode
@Raincode
Aug 08 2015 18:17
Sounds legit :)
Luis Felipe López G.
@luishendrix92
Aug 08 2015 18:18
It's just that the iterative array methods are the darling of some javascript develpers, instead of using fors and whiles they use map, forEach and reduce.
Less code to write I guess, more functional prowess perhaps.
Michael Christofersen
@mchristofersen
Aug 08 2015 18:22
Bonfire: Make a Person
CamperBot
@camperbot
Aug 08 2015 18:22
Sorry, can't find a bonfire called make a person. [ Check the map? ]
Feners4
@Feners4
Aug 08 2015 18:26
@jbmartinez interesting, let me try that
@jbmartinez that worked, why isnt this the best possible method?
Juan Martínez
@jbmartinez
Aug 08 2015 18:29
@Feners4 I like this shorter way because is easier, less code == less bugs, but it's not very flexible
@Feners4 the custom directive is better when you have many alternatives or you're working in a large project. I want to learn more about directives, I think that's the real power of angular
Tom Sun
@tomsun100
Aug 08 2015 18:35
Does anyone know how to make JQuery wait for a click event?
Tyler Haas
@tylerthehaas
Aug 08 2015 18:36
$().click()
$(selector).click() sorry for the confusion
Robert
@rc242
Aug 08 2015 18:40
heyo.
George Tsoukatos
@Gts0uk
Aug 08 2015 18:41
any help with the command line ?
on codecademy
David Sanchez
@wundertunge
Aug 08 2015 18:42
help with Dynamic HTML in JQuery
CamperBot
@camperbot
Aug 08 2015 18:42
no wiki entry for: with dynamic html in jquery
:pencil: click here to create one now!after creating your page type update to reload it here
David Sanchez
@wundertunge
Aug 08 2015 18:42
I'm on the exercise where it wants me to move a selected element two times, and I can't figure out the syntax
ALINATSUI
@ALINATSUI
Aug 08 2015 18:51
@robinsonKameron Trying to get more javascript practice
Tristanto
@rustyworks
Aug 08 2015 18:52
@tomsun100 You can use bind event
softeg
@softeg
Aug 08 2015 19:03
Hello
i need help to finish Bonfire: Make a Person my code is
var Person = function(firstAndLast) {
  var names = firstAndLast.split(' ');
  this.first = names[0];
  this.last  = names[1];
  this.firstAndLast = firstAndLast;
};

Person.prototype = {
  getFirstName:function() {
    return first;
  },
  getLastName:function() {
    return last;
  },
  getFullName:function() {
    return this.first + this.last;
  },
  setFirstName:function(first) {
    return this.first + this.last;
  },
  setLastName:function(last) {
    return this.first + this.last;
  },
  setFullName:function(firstAndLast) {
    var names = firstAndLast.split(' ');
    this.first = names[0];
    this.last  = names[1];
  },
};
var bob = new Person('Bob Ross');
bob.getFullName();
George
@sushiyea
Aug 08 2015 19:07
I need help with Waypoint: Responsively Style Checkboxes
Rockpile
@rock-pile
Aug 08 2015 19:08
hmm.. is 'Who's in Your Bracket' busted?
var james = {
    job: "programmer",
    married: false
};

// set to the first property name of "james"
var aProperty = "job";

// print the value of the first property of "james" 
// using the variable "aProperty"
console.log(james[aProperty]);
that should work, no?
Moisés Man
@moigithub
Aug 08 2015 19:10
@softeg for that exercise.... dont use prototype... move all ur methods inside ur Person class
remove this this.firstAndLast = firstAndLast;
and DO NOT use public properties (ex.: this.first ) but instead "local variables" (ex var first)
@camgoodman yes.. that shoudl work
Rockpile
@rock-pile
Aug 08 2015 19:11
@moigithub its failing.. bug with codeacademy?
Moisés Man
@moigithub
Aug 08 2015 19:11
try with another browser ? or refresh page ?
softeg
@softeg
Aug 08 2015 19:11
ok thanks @moigithub i will try this now
Rockpile
@rock-pile
Aug 08 2015 19:11
i reloaded the page and it worked
lol
Moisés Man
@moigithub
Aug 08 2015 19:11
:)
Da Cheezy Mobsta
@mobesa
Aug 08 2015 19:12
Hey everyone!!
George Tsoukatos
@Gts0uk
Aug 08 2015 19:13
guys any help with the command line ?
Da Cheezy Mobsta
@mobesa
Aug 08 2015 19:13
Need help on bonfire #27. Gotta' write down the issue here so hold on for a few mins...
George Tsoukatos
@Gts0uk
Aug 08 2015 19:13
on codecademy
Moisés Man
@moigithub
Aug 08 2015 19:15
@Gts0uk what u trying to do ?
George Tsoukatos
@Gts0uk
Aug 08 2015 19:15

2.
In the bash profile, beneath the aliases, on a new line, type

USER="Jane Doe"

Feel free to use your own name.

Save the file and press enter to write the filename.

I do that
and then it says : "Set the 'USER' environment variable in the bash profile."
it's a bug
Moisés Man
@moigithub
Aug 08 2015 19:17
post a link ?
im not sure if i did that... dont remember
George Tsoukatos
@Gts0uk
Aug 08 2015 19:17
it's new
they added this exercise today I think
Moisés Man
@moigithub
Aug 08 2015 19:18
ahh
so... post the link ? :)
George Tsoukatos
@Gts0uk
Aug 08 2015 19:20
ok I did it
what link ?
Moisés Man
@moigithub
Aug 08 2015 19:20
codeacademy
Moisés Man
@moigithub
Aug 08 2015 19:21
ye thats new to me....
George Tsoukatos
@Gts0uk
Aug 08 2015 19:21
you are welcome ;)
softeg
@softeg
Aug 08 2015 19:23
Pleaze can anyone give me trick to paste code correctly in chat ?
galacticfan
@galacticfan
Aug 08 2015 19:23
This message was deleted
This message was deleted
23crompton
@23crompton
Aug 08 2015 19:23
yeah like the pictures of code
how did u do that
and why was it deleted
galacticfan
@galacticfan
Aug 08 2015 19:24
you put ```
above and below the code
Da Cheezy Mobsta
@mobesa
Aug 08 2015 19:24

This is my solution to Bonfire #27

function unite(arr1, arr2, arr3) {
  var flat_arr = [arr1, arr2, arr2].reduce(function(a,b) {return a.concat(b);});
  var original_val_arr = flat_arr.filter(function(value, index){return index === flat_arr.indexOf(value);});
  return original_val_arr;
}

unite([1, 2, 3], [5, 2, 1, 4], [2, 1]);
unite([1, 3, 2], [1, [5]], [2, [4]]);

The problem here is that it seems logical and does work in a JS console but doesn't work in the Bonfire environment.
Help?

Shaklin
@ShaklinSyed
Aug 08 2015 19:24
start and at the end
23crompton
@23crompton
Aug 08 2015 19:24
'''test here'''
''' test here '''
Shaklin
@ShaklinSyed
Aug 08 2015 19:24
@23crompton use `
23crompton
@23crompton
Aug 08 2015 19:24
wheres that
softeg
@softeg
Aug 08 2015 19:25
where i can find key in my keyboard ?
23crompton
@23crompton
Aug 08 2015 19:25
dont think we have that on uk keyboard?
Shaklin
@ShaklinSyed
Aug 08 2015 19:25
do u see ~ sign on ur keyboard
Da Cheezy Mobsta
@mobesa
Aug 08 2015 19:25
on the tilde ~
23crompton
@23crompton
Aug 08 2015 19:25
~
#
i get #
Da Cheezy Mobsta
@mobesa
Aug 08 2015 19:25
what keyboard r u using?
Robert
@rc242
Aug 08 2015 19:26
@mobesa Doesn't work in my console.
Da Cheezy Mobsta
@mobesa
Aug 08 2015 19:26
QWERTY?
23crompton
@23crompton
Aug 08 2015 19:26
""" test """
uk qwerty
galacticfan
@galacticfan
Aug 08 2015 19:26
I have a UK keyboard and have that symbol
softeg
@softeg
Aug 08 2015 19:26
azerty :)
galacticfan
@galacticfan
Aug 08 2015 19:26
next to the 1 key
Da Cheezy Mobsta
@mobesa
Aug 08 2015 19:26
@rc242 Howcome?
23crompton
@23crompton
Aug 08 2015 19:26
@galacticfan wat key isit bro
Da Cheezy Mobsta
@mobesa
Aug 08 2015 19:26
@rc242 Wait a minute..
23crompton
@23crompton
Aug 08 2015 19:26
above the number 2
is "
galacticfan
@galacticfan
Aug 08 2015 19:26
@23crompton Contains 3 symbols to the left of the 1 key
above the tab key
23crompton
@23crompton
Aug 08 2015 19:27
`
`
`
Da Cheezy Mobsta
@mobesa
Aug 08 2015 19:27
@23crompton what kind of keyboard are you using...?
23crompton
@23crompton
Aug 08 2015 19:27
`
`
`
galacticfan
@galacticfan
Aug 08 2015 19:27
yeah
23crompton
@23crompton
Aug 08 2015 19:27
woop
Da Cheezy Mobsta
@mobesa
Aug 08 2015 19:27
@23crompton there you go!
23crompton
@23crompton
Aug 08 2015 19:27
code time
Shaklin
@ShaklinSyed
Aug 08 2015 19:27
voila
23crompton
@23crompton
Aug 08 2015 19:27
thanks to all that helped
Da Cheezy Mobsta
@mobesa
Aug 08 2015 19:27
lol
softeg
@softeg
Aug 08 2015 19:27
@moigithub itry with new code and tests tell me bob.geFullName() is not a fonctiont
23crompton
@23crompton
Aug 08 2015 19:28

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

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

h2 {
font-family: Lobster, Monospace;
}

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

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

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

softeg
@softeg
Aug 08 2015 19:28
var Person = function(firstAndLast) {
  var names = firstAndLast.split(' ');
  var first = names[0];
  var last  = names[1];

  getFirstName = function() {
    return first;
  };
  getLastName = function() {
    return last;
  };
  getFullName = function() {
    return first + last;
  };
  setFirstName = function(first) {
    first = first;
  };
  setLastName = function(last) {
    last =last;
  };
  setFullName = function(firstAndLast) {
    var names = firstAndLast.split(' ');
    first = names[0];
    last  = names[1];
  };
};


var bob = new Person('Bob Ross');
bob.getFullName();
23crompton
@23crompton
Aug 08 2015 19:28

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

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

h2 {
font-family: Lobster, Monospace;
}

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

```

Da Cheezy Mobsta
@mobesa
Aug 08 2015 19:28
@23crompton Put you ````
Robert
@rc242
Aug 08 2015 19:28
explain format
CamperBot
@camperbot
Aug 08 2015 19:28

: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

``` ⇦ Type 3 backticks, 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

Da Cheezy Mobsta
@mobesa
Aug 08 2015 19:28
on a seperate line
ok...?
23crompton
@23crompton
Aug 08 2015 19:29
holy sh#t that code bot is smart
did it post that because it noticed questions or did someone call it
galacticfan
@galacticfan
Aug 08 2015 19:30
it's reading the chat at the moment
Da Cheezy Mobsta
@mobesa
Aug 08 2015 19:30
i think there are certain messages that calls camperbot
softeg
@softeg
Aug 08 2015 19:30
@camperbot thanks it's works now
Robert
@rc242
Aug 08 2015 19:30
@23crompton It listens to keywords. there's a few commands you can give and it'll respond accordingly.
23crompton
@23crompton
Aug 08 2015 19:31
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

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

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

  .smaller-image {
    width: 100px;
  }
</style>
Da Cheezy Mobsta
@mobesa
Aug 08 2015 19:31
nice
Tyler St. Onge
@tylerstonge
Aug 08 2015 19:31
I have the solution to the Chunky Monkey Bonfire, but it seems inefficient. Can someone critique it and tell me how I could make it more precise?
```
23crompton
@23crompton
Aug 08 2015 19:31
@rc242 ahh thats sweet
Tyler St. Onge
@tylerstonge
Aug 08 2015 19:31

function chunk(arr, size) {
// Break it up.
var d1 = 0;
var d2 = 0;
var result = [];
result[d1] = [];
for(var i = 0; i < arr.length; i++) {
if(d2 >= size) {
d1++;
d2 = 0;
result[d1] = [];
}
result[d1][d2] = arr[i];
d2++;
}
return result;
}

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

softeg
@softeg
Aug 08 2015 19:31
@moigithub any idea why this happen ?
23crompton
@23crompton
Aug 08 2015 19:31
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

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

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

  .smaller-image {
    width: 100px;
  }
</style>
function chunk(arr, size) {
// Break it up.
var d1 = 0;
var d2 = 0;
var result = [];
result[d1] = [];
for(var i = 0; i < arr.length; i++) {
if(d2 >= size) {
d1++;
d2 = 0;
result[d1] = [];
}
result[d1][d2] = arr[i];
d2++;
softeg
@softeg
Aug 08 2015 19:32
var Person = function(firstAndLast) {
  var names = firstAndLast.split(' ');
  var first = names[0];
  var last  = names[1];

  getFirstName = function() {
    return first;
  };
  getLastName = function() {
    return last;
  };
  getFullName = function() {
    return first + last;
  };
  setFirstName = function(first) {
    first = first;
  };
  setLastName = function(last) {
    last =last;
  };
  setFullName = function(firstAndLast) {
    var names = firstAndLast.split(' ');
    first = names[0];
    last  = names[1];
  };
};


var bob = new Person('Bob Ross');
bob.getFullName();
can anyonne help me ? i have this message bob.getFullName in not a fonction.
galacticfan
@galacticfan
Aug 08 2015 19:33
@tylerstonge better to indent your code to make it more readable:
// Break it up.
var d1 = 0;
var d2 = 0;
var result = [];
result[d1] = [];
for (var i = 0; i < arr.length; i++) {
    if (d2 >= size) {
        d1++;
        d2 = 0;
        result[d1] = [];
    }
    result[d1][d2] = arr[i];
    d2++;
}
return result;
}
chunk(['a', 'b', 'c', 'd'], 2);
23crompton
@23crompton
Aug 08 2015 19:33
anyone here work with CPA?
Tyler St. Onge
@tylerstonge
Aug 08 2015 19:33
It was indented on mine, I guess it went away when I copied and pasted
galacticfan
@galacticfan
Aug 08 2015 19:34
@tylerstonge here is mine if you wanted to compare: http://pastebin.com/E793x8C9
Robert
@rc242
Aug 08 2015 19:35
@softeg you'll need to attach your functions to the Person object. You can do this by adding "this.getFullName = function() ..."
Moisés Man
@moigithub
Aug 08 2015 19:35
@softeg all u methods are "public methods" part of ur person class.. u need to add "this" keyword so they can be acccessed from outside
this.getFirstName
Tyler St. Onge
@tylerstonge
Aug 08 2015 19:35
Definitely! Thank you, @galacticfan.
Robert
@rc242
Aug 08 2015 19:36
bonfire chunky monkey
CamperBot
@camperbot
Aug 08 2015 19:36

: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.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

type: bf details bf links bf spoiler

Robert
@rc242
Aug 08 2015 19:38
@tylerstonge that's fine, I suppose. I'm sure it does the same things as implementations using Array.splice().
Da Cheezy Mobsta
@mobesa
Aug 08 2015 19:38

@rc242 @everyone > Hi this is CamperBot! I can assist 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 BFNAME info on a bonfire

:unlock: More commands and info

:pencil: read more about camperbot on the FCC Wiki

Robert
@rc242
Aug 08 2015 19:38
@tylerstonge with that said, you may be more concerned with readability than efficacy.
Da Cheezy Mobsta
@mobesa
Aug 08 2015 19:39
thanks @rc242
CamperBot
@camperbot
Aug 08 2015 19:39
mobesa sends brownie points to @rc242 :sparkles: :thumbsup: :sparkles:
Tyler St. Onge
@tylerstonge
Aug 08 2015 19:39
@rc242 Yeah, I guess my variables aren't very descriptive.
ALINATSUI
@ALINATSUI
Aug 08 2015 19:39
This message was deleted
Robert
@rc242
Aug 08 2015 19:40
@tylerstonge Well, I was talking more like using Array.splice to give you an array rather than iterating over your input array to generate the output.
Da Cheezy Mobsta
@mobesa
Aug 08 2015 19:40
help
CamperBot
@camperbot
Aug 08 2015 19:40

Hi this is CamperBot! I can assist 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 BFNAME info on a bonfire

:unlock: More commands and info

:pencil: read more about camperbot on the FCC Wiki

ALINATSUI
@ALINATSUI
Aug 08 2015 19:41
This message was deleted
CamperBot
@camperbot
Aug 08 2015 19:41
Sorry, can't find a bonfire called title case a sentence . [ Check the map? ]
dc
@dcsan
Aug 08 2015 19:41
bonfire title
CamperBot
@camperbot
Aug 08 2015 19:41

:fire:Bonfire: Title Case a Sentence :link:

function titleCase(str) {
  return str;
}

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

Return the provided string with the first letter of each word capitalized.
For the purpose of this exercise, you should also capitalize connecting words like 'the' and 'of'.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

type: bf details bf links bf spoiler

dc
@dcsan
Aug 08 2015 19:41
@ALINATSUI you just need part of the name...
ALINATSUI
@ALINATSUI
Aug 08 2015 19:41
bonfire Title Case
CamperBot
@camperbot
Aug 08 2015 19:41

:fire:Bonfire: Title Case a Sentence :link:

function titleCase(str) {
  return str;
}

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

Return the provided string with the first letter of each word capitalized.
For the purpose of this exercise, you should also capitalize connecting words like 'the' and 'of'.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

type: bf details bf links bf spoiler

ALINATSUI
@ALINATSUI
Aug 08 2015 19:41
thanks @dcsan
CamperBot
@camperbot
Aug 08 2015 19:41
alinatsui sends brownie points to @dcsan :sparkles: :thumbsup: :sparkles:
:star: 33 | @dcsan | http://www.freecodecamp.com/dcsan
ALINATSUI
@ALINATSUI
Aug 08 2015 19:42
How do I include code here ('cause I need help)?
Tried ```
dc
@dcsan
Aug 08 2015 19:42
help format
CamperBot
@camperbot
Aug 08 2015 19:42

: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

``` ⇦ Type 3 backticks, 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