These are chat archives for FreeCodeCamp/Help

10th
Aug 2015
Tom Pyszczuk
@Ne0nite
Aug 10 2015 00:00
dont mind the commented lines , this was just my last not working approach
Kolloom
@Kolloom
Aug 10 2015 00:01
@Ne0nite longest.length += stringReplace[i].length ; what does this line do?
Tom Pyszczuk
@Ne0nite
Aug 10 2015 00:02
@Kolloom Like I said please dont mind the commented out code . This is jsut some weird me trying out weir ways to make it work . So for now all I have working is the code above it which splits the string into array and then prints out the array, after that it prints out the words with the character number
Zeljko Sevic
@schewmeister
Aug 10 2015 00:03
@Kolloom some functions in my code don't work, but on jsfuddle works fine
Moisés Man
@moigithub
Aug 10 2015 00:03
length is a string property.. u cant assign values to a property
for that commented code work.. u need to do 3 things
Tom Pyszczuk
@Ne0nite
Aug 10 2015 00:04
but to clarify (i was doing that eysterday pretty braindead already) as far as I remember I wanted to make a var longest with 0 chars then go over every array property and check if it is longer than "longest" if not then add the length of the [i] to the var longest and do this untill it finished
dont know if that made any sense
:)
Moisés Man
@moigithub
Aug 10 2015 00:04
  1. move var longest = ""; outside ur for loop.. else everytime it loops it will "reset" back to ""
Anthony MacMahon
@SansPulp
Aug 10 2015 00:05

@Kolloom So I've changed it to this, where the return true statement sits outside the for loop.

function mutation(arr) {
  var baseStr = arr[0].toLowerCase();
  var searchStr = arr[1].toLowerCase().split('');

  for (i = 0; i < searchStr.length; i++) {
    if (baseStr.indexOf(searchStr[i]) === -1) { 
        return false;
    }
  }
 return true;
}
mutation(['hello', 'hey']);

Is that kind of cheating though, or really sloppy programming somehow? I'm wondering if I'm really checking what I'm supposed to be checking anymore.

Moisés Man
@moigithub
Aug 10 2015 00:05
2. longest.length +=.... line.. should be
longest = stringReplace[i]; // <-- that wil store the longest word
Kolloom
@Kolloom
Aug 10 2015 00:05
you have defined longest as an empty string, that tells me that you will holding a string with longest, yet longest.length is a number, the length of the string longest. that line makes no sense, you defined longest but never use it inside the loop
Moisés Man
@moigithub
Aug 10 2015 00:06
and finally.. ur function should return a result...
so at end of ur loop.. return longest; or return longest.length;
Tom Pyszczuk
@Ne0nite
Aug 10 2015 00:06
Kollon yes because that code is not finished .. Like I said please dont mind the commented out code it was jsut for me to remmeber what I was doing as last attempt yesterday.
Robert
@rc242
Aug 10 2015 00:06
@moigithub I think what you mean is that String is immutable. I don't think the property has anything to do with it.
Tom Pyszczuk
@Ne0nite
Aug 10 2015 00:07
I think the approach with the var longest is not a good approach anyway
Moisés Man
@moigithub
Aug 10 2015 00:07
@Ne0nite read my comments apply to ur code.. n do test... :) it should work
Kolloom
@Kolloom
Aug 10 2015 00:07
@sanspulp the idea is that if !!any!! character in hey is not in hello, it will return false, but to return true , all character in hey must be in hello (which means looping though the entire string hello
Tom Pyszczuk
@Ne0nite
Aug 10 2015 00:07
@moigithub Will do :)
Anthony MacMahon
@SansPulp
Aug 10 2015 00:09
@Kolloom So it will finish the for loop, never satisfy the if condition, and then move on and return true?
Moisés Man
@moigithub
Aug 10 2015 00:10
@SansPulp code looks good.. almost same like mine :) except i didnt use split.. cuz u still can access to string character like an array
Kolloom
@Kolloom
Aug 10 2015 00:10
exactly @SansPulp
Anthony MacMahon
@SansPulp
Aug 10 2015 00:10
@Kolloom Okay, cool. Thanks for the help!
Tom Pyszczuk
@Ne0nite
Aug 10 2015 00:15
@moigithub Wow thanks it worked. So I was on the right track afterall half braindead yesterday night :) Thank You!
Moisés Man
@moigithub
Aug 10 2015 00:15
:D
Kolloom
@Kolloom
Aug 10 2015 00:16
@Ne0nite to add, longest.length does not hold value, it's a function that returns the length of longest
Tom Pyszczuk
@Ne0nite
Aug 10 2015 00:18
@Kolloom Noted, Thank You :)
sinsukh
@sinsukh
Aug 10 2015 00:43
anynone know how to do Convert HTML Entities?
anyone*
Alex Litel
@alexlitel
Aug 10 2015 00:46
What am I doing wrong on the Roman numeral conversion
function convert(num) {
var newArr = [];
  var newNum = num.toString().split('');

    newNum[0] = parseInt(newNum[0]);
  if (newNum.indexOf[1] !== null) {

    newNum[1] = parseInt(newNum[1]);
  } else {
    newNum.pop();
  }

  console.log(newNum);

  function toRomanNumerals(arrNum) {
    if (arrNum>0 && arrNum <4) {
      newArr.push(Array(arrNum).join("I"));
    } else if (arrNum == 4) {
      newArr.push("IV");
    } else if (arrNum == 5) {
            newArr.push("V");
    } else if (arrNum>5 && arrNum < 9) {
        var newNum = arrNum - 5;
           console.log(Array(newNum).join("I"));
            newArr.push("V" + Array(arrNum-5).join("I"));

    } else {
            newArr.push("IX");
    } 
  }


  /* (function addToArray() {
  if (num>10) {
  newArr.push(round);
  newArr.push(num - round);
  console.log(newArr);
} else {
  newArr.push(num);
}
  }()); */

  console.log(newNum.length);

  (function conversion() {
    if (newNum.indexOf[1] !== null) {
      newArr.push(Array(newNum[0]).join("X"));
      toRomanNumerals(newNum[1]);
    } else {
      toRomanNumerals(newNum[0]);
    }
  }());

 num = newArr.join(""); 

console.log(newArr);
  console.log(num);

 return num;
}

convert(36);
convert(5);
convert(12);
convert(9);
convert(29);
SojournerOctocat
@SojournerOctocat
Aug 10 2015 00:57
@Singhsukh Yes. What's your question?
Clayton
@cjg040103
Aug 10 2015 01:08
k i'm bak.
wuz playing xbox
Alex Litel
@alexlitel
Aug 10 2015 01:12
Nevermind. figured it out
Kolloom
@Kolloom
Aug 10 2015 01:12
@alexlitel what's the point of parseInt ?
Alex Litel
@alexlitel
Aug 10 2015 01:12
@l
@kl
sinsukh
@sinsukh
Aug 10 2015 01:12
Screen Shot 2015-08-09 at 9.11.37 PM.png
@SojournerOctocat
Alex Litel
@alexlitel
Aug 10 2015 01:13
@Kolloom It was to convert the split string to numbers.
sinsukh
@sinsukh
Aug 10 2015 01:13
not sure why some aren't passing
Kolloom
@Kolloom
Aug 10 2015 01:15
bonfire convert
CamperBot
@camperbot
Aug 10 2015 01:15

:fire:Bonfire: Roman Numeral Converter :link:

function convert(num) {
 return num;
}

convert(36);

Convert the given number into a roman numeral.
All <a href="http://www.mathsisfun.com/roman-numerals.html">roman numerals</a> answers should be provided in upper-case.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

type: bf details bf links bf spoiler

Kolloom
@Kolloom
Aug 10 2015 01:16
bonfire html
CamperBot
@camperbot
Aug 10 2015 01:16

: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

Kolloom
@Kolloom
Aug 10 2015 01:16
@Singhsukh there are 2 more characters you need to replace: ", '
Chris LaFave
@chrislafave
Aug 10 2015 01:18
function unite(arr1, arr2, arr3) {
  var merge = function(coll,item) {
    if (coll.indexOf(item) < 0)
      coll.push(item);
    return coll;
  };
  //TODO this can be simplified
  arr1 = arr2.reduce(merge, arr1);
  arr1 = arr3.reduce(merge, arr1);
  return arr1;
}
unite([1, 2, 3], [5, 2, 1, 4], [2, 1]);
I've already submitted an answer for "Sorted Union" but it was without using "reduce", which uses a "callback function". The answer that I've found, shown above uses it.
I've spent several hours so far trying to understand where "merge" gets its arguments. I understand from reduce's prototype that its first argument is a callback function (which is merge in this case), and I get what a callback function is. And the callback function's arguments are supposedly: (previousValue, currentValue, index, array) when being called by "reduce", which steps, one-by-one, through the arrays somehow using merge. Maybe "item" matches up with being currentValue, but that's it.
I don't know where someone's supposed to learn this type of programming because there are no examples like it in "prototypes" and "callback functions" where arguments required seem to change depending on context.
I would greatly appreciate someone explaining the above example to me or at least where the heck I would learn to do what's apparently been done in this example.
chris dot r dot lafave at gmail dot com
Migh_T_Reuben
@treuben
Aug 10 2015 01:20
Is anyone willing to help me with a Git exercise I am working on?
Juan Martínez
@jbmartinez
Aug 10 2015 01:22
@treuben I'll try
Kolloom
@Kolloom
Aug 10 2015 01:25
find reduce
CamperBot
@camperbot
Aug 10 2015 01:25
find reduce
nothing found
Migh_T_Reuben
@treuben
Aug 10 2015 01:25

@jbmartinez - thank you! Im am working on the following exercise: http://gitimmersion.com/lab_03.html

I understand and completed this - EXECUTE: $mkdir hello and $cd hello. But I do not understand how to do this - FILE: hello.rb puts "Hello, World". I need to know the exact steps because what I am doing is not working.

Kolloom
@Kolloom
Aug 10 2015 01:27
@treuben make a file hello.rb and add puts "Hello, World" in it?
that looks like a ruby script file
Migh_T_Reuben
@treuben
Aug 10 2015 01:28
@Kolloom - do I do this through the terminal? I typed hello.rb into the terminal and it returned: -bash: hello.rb: command not found
Kolloom
@Kolloom
Aug 10 2015 01:28
you can do it however you want
Migh_T_Reuben
@treuben
Aug 10 2015 01:29
@Kolloom - I don't understand what I am supposed to complete this exercise at all.
Juan Martínez
@jbmartinez
Aug 10 2015 01:29
@treuben do what @Kolloom said. You can write puts "Hello, World" in any editor
@treuben and save the file in the folder you're working on
@treuben you're file should be a text file and must have the name hello.rb
Migh_T_Reuben
@treuben
Aug 10 2015 01:31

@jbmartinez @Kolloom - please look at terminal input. What am I doing wrong:

Taiwos-MacBook-Pro:hello taiworeuben$ hello.rb
-bash: hello.rb: command not found
Taiwos-MacBook-Pro:hello taiworeuben$ ruby -v
ruby 2.0.0p643 (2015-02-25 revision 49749) [x86_64-darwin14.1.0]
Taiwos-MacBook-Pro:hello taiworeuben$ puts "Hello, World"
-bash: puts: command not found
Taiwos-MacBook-Pro:hello taiworeuben$

Juan Martínez
@jbmartinez
Aug 10 2015 01:33
@treuben if you need to create the file from the terminal (I not recommend it) you can write this:
Kolloom
@Kolloom
Aug 10 2015 01:34
echo puts "Hello, World" > hello.rb
Juan Martínez
@jbmartinez
Aug 10 2015 01:34
echo puts "Hello, World" > hello.rb
Migh_T_Reuben
@treuben
Aug 10 2015 01:34
@jbmartinez - Just curious, why do you not recommend it.
Juan Martínez
@jbmartinez
Aug 10 2015 01:34
oops! I'm too slow with markdown
Migh_T_Reuben
@treuben
Aug 10 2015 01:35
@jbmartinez - that's okay! :)
Thank you Kolloom! :)
Juan Martínez
@jbmartinez
Aug 10 2015 01:35
@treuben because it's better to be focused in one thing when you're learning
@treuben if you're learning git it's better to do all other tasks in a usual way
@treuben and modern text editors have many advantages
Migh_T_Reuben
@treuben
Aug 10 2015 01:40
@jbmartinez - I see what you are saying. I am extremely new at this. So I was not sure what the usual way of creating the file was. I still don't understand how I could have done it the usual way. I use Sublime text. Could you explain it further so I will know. I really want to understand.
@jbmartinez - So if I opened Sublime text. Typed in Hello World. Then saved it as "hello.rb". Is this what you mean?
Juan Martínez
@jbmartinez
Aug 10 2015 01:43
@treuben exactly! just save it in the working folder
@treuben but you should type puts "Hello, World"
SojournerOctocat
@SojournerOctocat
Aug 10 2015 01:45
@Singhsukh I would suggest using regex.
Kolloom
@Kolloom
Aug 10 2015 01:46
how do i return undefined with ternary expression ?
Migh_T_Reuben
@treuben
Aug 10 2015 01:47
@jbmartinez - So in Sublime I literally type this in: puts "Hello, World"? I just want to make sure I am understanding correctly before I do it. Thank you.
Kolloom
@Kolloom
Aug 10 2015 01:48
the stuff you put into the file is an expression in ruby, prints the string "Hello, World" @treuben
somewhat similar to console.log
Migh_T_Reuben
@treuben
Aug 10 2015 01:50
@Kolloom - Ohhhhh. Okay. Cool. Thank you!
Juan Martínez
@jbmartinez
Aug 10 2015 01:50
@treuben yes, you should write it all
Migh_T_Reuben
@treuben
Aug 10 2015 01:52
@jbmartinez -Thank you so much for clearing this up for me! This has been frustrating me since last week. I just didn't understand. But I get it now. The Git Immersion tutorial makes the assumption you understand what their shorthand instruction means but I didn't until know. Thank you so much. Now I finally proceed with the rest of the tutorial. I appreciate you! :smile:
@Kolloom - Thanks for help as well. I appreciate you too! :)
Kolloom
@Kolloom
Aug 10 2015 01:53
:+1:
Juan Martínez
@jbmartinez
Aug 10 2015 01:54
@treuben no problem :smiley:
Migh_T_Reuben
@treuben
Aug 10 2015 01:55
I am really beginning to dig being in this chatroom! I'm so happy right now. :clap: :sparkles: :sparkles: :sparkles:
Reggie
@Reggie01
Aug 10 2015 01:56

@chrislafave Answering your last question first. Where the heck I would learn to do what's apparently been done in this example? I don't have really have a concrete answer. Bonfires introduce a lot of functions that require callbacks. So I have been learning functional programming through following helpful links in Bonfires and then trying them out in my code. Also, someone posted this link https://www.youtube.com/channel/UCO1cgjhGzsSYb1rsB4bFe4Q/playlists where a guy explains functional programming. I suggest you watch them. On to the code

function unite(arr1, arr2, arr3) {
  var merge = function(coll,item) {  // Here arr1 is initial value for callback so coll = arr1
    console.log(coll);  // Here we are double-checking arr1 = coll
    /*  item refers to elements in arr2 in the first function.   arr2.reduce(merge, arr1)
           arr2 = [5, 2, 1, 4];   arr3 = [2, 1];
            Then elements in arr3 in the second function.  arr3.reduce(merge, arr1)
 */
    console.log(item); 
    /* is the item aka element in arr1 === [1,2,3]; So if  arr2.reduce(merge, arr1); Then arr2 at element 0 is 5.
         So is 5 in arr1.
    */
    if (coll.indexOf(item) < 0) 
      coll.push(item);  // Then if item is not in array 1 add the item to array one
    return coll;
  };
  //TODO this can be simplified
  arr1 = arr2.reduce(merge, arr1);  // so reduce can take 2 values.  arr.reduce(callback[, initialValue]) <- check link below
  arr1 = arr3.reduce(merge, arr1);  // arr1 is our initial value  === [1,2,3]
  return arr1;
}
unite([1, 2, 3], [5, 2, 1, 4], [2, 1]);

Try running this in your console. Re-read https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce and just think really hard for a sec. I annotated code for you.

Valerie M
@SerenityFL
Aug 10 2015 01:57
@treuben I know your pain about the assumptions in the tutorials.
Chris LaFave
@chrislafave
Aug 10 2015 01:58
@Reggie01 You rock! :) I'll check those out right away. Thanks Reggie!
Reggie
@Reggie01
Aug 10 2015 01:58
@chrislafave
if (coll.indexOf(item) < 0) 
      coll.push(item);  // Then if item is  in array 1 add the item to array one
    return coll;
@chrislafave Cool, hope it helps you.
Migh_T_Reuben
@treuben
Aug 10 2015 02:02
@SerenityFL - Glad to know I am not alone. Sheesh. lol :)
Kolloom
@Kolloom
Aug 10 2015 02:03
var merge = function(coll,item) i don't know how coll is assigned with the value of arr1? @Reggie01
find callback
CamperBot
@camperbot
Aug 10 2015 02:05
find callback
nothing found
Reggie
@Reggie01
Aug 10 2015 02:06
@Kolloom the initial value passed in reduce is passed to the callback
Kolloom
@Kolloom
Aug 10 2015 02:06
oh, i though it was defined with one
no need for declaring coll with var ?
Reggie
@Reggie01
Aug 10 2015 02:13

@Kolloom hmm, not sure what your asking. Are you saying

 var something = coll;

then passing merge the argument coll. Like

merge(something, item);
Kolloom
@Kolloom
Aug 10 2015 02:15
i mean is every coll in that function is replace with arr1?
the function is pushing item to the first parameter itself?
Reggie
@Reggie01
Aug 10 2015 02:24

@Kolloom cleaner version of merge function that was being used

 var merge = function(coll,item) {

    if (coll.indexOf(item) < 0) // condition
      coll.push(item);
    return coll;
  };

so initially arr1 is [1, 2, 3], so yes the item is being pushed to the array if the conditional is true.

Reggie
@Reggie01
Aug 10 2015 02:33

@Kolloom

// arr2 = [5, 2, 1, 4];   arr1 = [1, 2, 3];
 arr1 = arr2.reduce(merge, arr1);  // result is  [ 1, 2, 3, 5, 4 ]

Now arr1 is eqal to [ 1, 2, 3, 5, 4 ]

/* arr3 = [2, 1];   so nothing happens this time around because array 3 values are already  in arr1. 
  arr1 = arr3.reduce(merge, arr1);
@Kolloom does that answer your question?
Kolloom
@Kolloom
Aug 10 2015 02:44
i feel that the function merge is called without any parameter
are the parameters supplied by the reduce?
Alejandro Tejada
@wannabecoding
Aug 10 2015 02:46

'''
function factorialize(num) {
if (num === 0)
{ return 1; }
else
{ return num * factorialize(num - 1); }
return num;
}

factorialize(5);

how do I submit in that format that you've used @Reggie01 ?
Kolloom
@Kolloom
Aug 10 2015 02:47
wiki format
CamperBot
@camperbot
Aug 10 2015 02:47

: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

Alejandro Tejada
@wannabecoding
Aug 10 2015 02:48
function factorialize(num) {
  if (num === 0)
      { return 1; }
    else
      { return num * factorialize(num - 1); }
  return num;
}

factorialize(5);
I was messing around when I got this, somehow, it works. I don't understand how it factorializes my input when it's not a loop
Rex Schrader
@SaintPeter
Aug 10 2015 02:49
@wannabecoding It's a recursive statement. See how it calls itself?
return num * factorialize(num - 1);
All of those function calls must be resolved before it can do the math
So it ends up resolving like:
5 * (4 * (3 * (2 * (1))))
Kolloom
@Kolloom
Aug 10 2015 02:50
i don't think the last return will ever be hit? @wannabecoding
Rex Schrader
@SaintPeter
Aug 10 2015 02:51
Correct, that last return will never be hit
Alejandro Tejada
@wannabecoding
Aug 10 2015 02:51
Ok. So the return num in the else statement uses the 5 called in factorialize
sorry, I'm just having trouble wording it
the last return num is not neccesary, i see that now
Alejandro Tejada
@wannabecoding
Aug 10 2015 03:16
Why would it stop once it reaches 1? Cause of the if statement?
Rex Schrader
@SaintPeter
Aug 10 2015 03:16
@wannabecoding Well, once it gets to 0, then it returns a 1 . . .and it just precolates up the chain
@wannabecoding Recursive functions can be powerful and usually easy to read, but they're also dangerous - if you don't know how they stop, they'll go on forever. They're also not always the most effecient way to solve problems, due to the overhead associated with calling functions.
Robert Richey
@0x0936
Aug 10 2015 03:18
@wannabecoding it stops calling itself at num === 0
Robert
@rc242
Aug 10 2015 03:18
that stack memory.
Alejandro Tejada
@wannabecoding
Aug 10 2015 03:19
Yea I was just reading up on it
Robert
@rc242
Aug 10 2015 03:19
that laziness with getting local weather zipline done.
Rex Schrader
@SaintPeter
Aug 10 2015 03:20
@rc242 Joo can dooooo eeeeet
Alejandro Tejada
@wannabecoding
Aug 10 2015 03:20
I tried a large number and got an overflow
Lol
Rex Schrader
@SaintPeter
Aug 10 2015 03:21
Yup . . . although that's more of the nature of factorials than recursive stuff.
The get big fast
Reggie
@Reggie01
Aug 10 2015 03:21
@Kolloom https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce explains reduce better than I can. The callback in reduce can be called with 4 arguments like callback(previousValue, currentValue, index, array). In our case the callback is called with the parameters previousValue and currentValue. callback(previousValue, currentValue) previousValue can be replaced with InitialValue if one is passed. In our case InitialValue = arr1. currentValue is the current element being processed in the array. <-- our place in arr2 or arr3.
Robert
@rc242
Aug 10 2015 03:22
@SaintPeter banged my head on trying to get the toggle btn done. I was getting way OCD on the alignment.
Alejandro Tejada
@wannabecoding
Aug 10 2015 03:24
I will read up on it some more tomorrow
Thanks guys.
Have a good night
Robert
@rc242
Aug 10 2015 03:24
and then looking at the temperature, it makes me wanna move back to Seattle.
92F ... and it's past 10.
Rex Schrader
@SaintPeter
Aug 10 2015 03:33
@rc242 That's about like Sacramento. We get a month or two of tripple digit temperatures
Robert
@rc242
Aug 10 2015 03:45
@SaintPeter oh yeah? A couple years ago, Dallas got 71 days of it. It was misery. :(
SaintPeter @SaintPeter shudders
Rex Schrader
@SaintPeter
Aug 10 2015 03:47
@rc242 Dallas is worse than Sac, though - it's 100 degrees with 100% humidity. As they say, in Sac, at least it's a DRY heat.
i need to align the "search" right under All, Online, Offline
how u do that with bootstrap and css
Robert
@rc242
Aug 10 2015 03:49
No, no. The humidity in Dallas isn't really that bad. It's much too far inland. Now, if you want hot and humid, you should check out Houston.
John Chau
@ydjjabt
Aug 10 2015 03:50
@rc242 Hey, watch out for martial law and jade helm 15 lol
also fluoride and radioactivity in ur water lol
@rc242 Uncle Shame aint shameful at all
Robert
@rc242
Aug 10 2015 03:53
... hookay.
John Chau
@ydjjabt
Aug 10 2015 03:57
http://codepen.io/ydjjabt/pen/ZGVXNv
How u can the logo/icon smaller
Rex Schrader
@SaintPeter
Aug 10 2015 03:57
@ydjjabt If you look at the thumbnail URL, you'll see that they actually have a suffix that is dimensions
@ydjjabt I think it defaults to 300x300 (as part of the filename)
@ydjjabt You can actually change that to 50x50 or whatever (search and replace) and the server will serve up the appropriate size image.
there no dimension
John Chau
@ydjjabt
Aug 10 2015 04:02
search and replace???? come on
oh
how u get that??u just put 50x50?
Rex Schrader
@SaintPeter
Aug 10 2015 04:02
Yup
John Chau
@ydjjabt
Aug 10 2015 04:02
man FCC does make u WORk hard on these zipline
Rex Schrader
@SaintPeter
Aug 10 2015 04:02
Like I said, search and replace
what u mean search and replace...englighten me!
Rex Schrader
@SaintPeter
Aug 10 2015 04:04
I mean
var url = 'http://static-cdn.jtvnw.net/jtv_user_pictures/medrybw-profile_image-19fce7e1b0d6c194-300x300.jpeg'
var smallerPic = url.replace('300x300', '50x50');
John Chau
@ydjjabt
Aug 10 2015 04:04
@SaintPeter THANKS
mad prop man
Rex Schrader
@SaintPeter
Aug 10 2015 04:04
NP, glad to help
John Chau
@ydjjabt
Aug 10 2015 04:05
that a string method, nice
Rex Schrader
@SaintPeter
Aug 10 2015 04:05
@ydjjabt Have you not done the Bonfires yet?
John Chau
@ydjjabt
Aug 10 2015 04:08
@SaintPeter i did the bonfires but i didnt learn about application
@SaintPeter

var smallerPic = url.replace('300x300', '50x50');
// can u not put '300x300'? i mean what if some logo/icon is different size than 300x300...lol
Rex Schrader
@SaintPeter
Aug 10 2015 04:11
@ydjjabt Well, your mileage may vary. You could also write a regular expression:
/\d+x\d+\./
John Chau
@ydjjabt
Aug 10 2015 04:12
nice man
Rex Schrader
@SaintPeter
Aug 10 2015 04:13
I'm out - TTYL
John Chau
@ydjjabt
Aug 10 2015 04:13
good nite
JessicaEx
@JessicaEx
Aug 10 2015 04:17
Can someone help me with the Inventory Update Bonfire? Am I getting the problem wrong because the arrays are out of order, or is there something else wrong with my code?
CamperBot
@camperbot
Aug 10 2015 04:17
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
JessicaEx
@JessicaEx
Aug 10 2015 04:17
function inventory(arr1, arr2) {
    // All inventory must be accounted for or you're fired!

    for (var elm in arr2){
        var check = true;
        for (var elt in arr1){
            if (arr2[elm][1] === arr1[elt][1]){
                arr1[elt][0] = arr1[elt][0] + arr2[elm][0];
                check = false;
            }
        }
        if (check){
            arr1.push(arr2[elm]);
        }
    }
    return arr1;
}
Robert
@rc242
Aug 10 2015 04:18
bonfire inventory
CamperBot
@camperbot
Aug 10 2015 04:18
Sorry, can't find a bonfire called inventory. [ Check the map? ]
Robert
@rc242
Aug 10 2015 04:18
oh, is that an intermediate?
JessicaEx
@JessicaEx
Aug 10 2015 04:19
It's one of the advanced ones I think
Should I ask this somewhere else?
Robert
@rc242
Aug 10 2015 04:19
oh, I see.
i just need to understand what it's supposed to do.
so, you're supposed to have the items in alphabetical order.
JessicaEx
@JessicaEx
Aug 10 2015 04:21
Ughh... I read the instructions several times, and still missed that bit.
Robert
@rc242
Aug 10 2015 04:21
It's okay.
JessicaEx
@JessicaEx
Aug 10 2015 04:21
Thanks for the help.
João Fortunato
@jfortunatojr
Aug 10 2015 04:39

Hi guys I'm stuck with Falsey Bouncers
Here is my code

function bouncer(arr) {
    for (var i = 0; i < arr.length; i++) {
        if (!Boolean(arr[i])) {
            arr.splice(i, 1);
        }
    }
    console.log(arr);
    return arr;
}

bouncer(['', false, NaN, 0, null, undefined]);

If I make a for loop to console.log(Boolean(arr[i])) all the elements in the array, they will all be logged as false but when I put them inside an If some of them become true...

Leandro Santos
@leaudro
Aug 10 2015 04:47
@joaofortunato I think you should use new Boolean instead of just Boolean
Robert Richey
@0x0936
Aug 10 2015 04:54
@joaofortunato You can check for a truthy value without having to cast to Boolean. if (!arr[i]) { arr.splice(i, 1) }
Robert
@rc242
Aug 10 2015 04:58
Not sure if using splice is even a good idea.
@joaofortunato if you want to use splice, you'll want to increment your idx elsewhere, not in the for loop.
@joaofortunato er, well, in the for loop, just not where you have it.
Robert Richey
@0x0936
Aug 10 2015 05:03
@joaofortunato Look into MDN - Array.prototype.filter, and this bonfire becomes a one line solution.
Robert
@rc242
Aug 10 2015 05:07
Falsey Bouncer is part of the basic scripting bonfires. So, he probably hasn't done the functional programming stuff.
@joaofortunato if you're still having issues, let @0x0936 or I know. I'm sure one of us can answer your questions. Don't want you stuck on the problem, but would rather you read a little on the APIs and maybe find the answer.
João Fortunato
@jfortunatojr
Aug 10 2015 05:12
Thanks guys I'll take a look at the materials. What you said have already helped me. Just wanted to understand why the the items in the array where false while logging to console but true when put in the If function.
Robert
@rc242
Aug 10 2015 05:14
@joaofortunato You have "!" in front of your conditional. Try removing the ! and they should be false.
ahmeddin
@ahmeddin
Aug 10 2015 05:19
left two days back when i could not solve dna pairing problem, can anyone hint what i need to do.....
Robert Richey
@0x0936
Aug 10 2015 05:19
// an alternative
function bouncer(arr) {
  var newArr = []; // push truthy values to this array, then return it
  // todo
}

bouncer(['', false, NaN, 0, null, undefined]);
Luis Felipe López G.
@luishendrix92
Aug 10 2015 05:19
@joaofortunato Just use Array.prototype.filter, you should also know that those elements in the array are the values often called falsey values which when evaluated it turns into false. For example if you put '' inside an IF statement, it will evaluate as FALSE.
Bill
@kirah1314
Aug 10 2015 05:19
'''
Dayne Wright
@daynewright
Aug 10 2015 05:20
Hi..can someone help me with this question?
// -> Define an object called 'Robot'
// -> Define a method called 'new' in Robot
// -> When Robot.new is called it should return a new object with Robot as its prototype 
//    e.g. var robby = Robot.new();
//    Robot should be the prototype of robby

var Robot = {
     new: function(){
       return this.Robot = {};
    }  
};

var robby = Robot.new();
Robert
@rc242
Aug 10 2015 05:21
@ahmeddin Do you have anything yet?
Luis Felipe López G.
@luishendrix92
Aug 10 2015 05:22
@Daynewr Is that from NodeSchool? I am not sure but you might have to return new Robot()
ahmeddin
@ahmeddin
Aug 10 2015 05:22
i have no idea..
Dayne Wright
@daynewright
Aug 10 2015 05:22
@luishendrix92 Yes. NodeSchool from the beta.freecodecamp
ahmeddin
@ahmeddin
Aug 10 2015 05:23
@rc242
Luis Felipe López G.
@luishendrix92
Aug 10 2015 05:23
Instead of this.Robot = {}
For starters, there is not a Robot property inside the object Robot (which is a constructor), and second, you can't return an assignment.
ahmeddin
@ahmeddin
Aug 10 2015 05:24
u there @rc242
Dayne Wright
@daynewright
Aug 10 2015 05:25
@luishendrix92 ok. I am getting lost on this one.
ahmeddin
@ahmeddin
Aug 10 2015 05:25
u can tell me at least how to start thinking...
Luis Felipe López G.
@luishendrix92
Aug 10 2015 05:27
@Daynewr Try this (though I'm not yet sure):
var Robot = {
     new: function(){
       return this;
    }  
};

var robby = Robot.new();
Dayne Wright
@daynewright
Aug 10 2015 05:28

@luishendrix92

✓ Submission results match expected
✓ exports a Robot variable
✓ Robot.new is defined
✓ Robot.new is a function
✓ Robot.new returns an object
✗ Robot is the prototype of robby

# FAIL

close it seems

still not getting it as a prototype. The instructions up to this point have been helpful except this challenge didn’t seem to give any guidance.
Luis Felipe López G.
@luishendrix92
Aug 10 2015 05:32

Ok last try and I'm off to sleep haha, I'm really not sure since I haven't got to NodeSchool yet.

function Robot() {
  this.new = function() {
    return new Robot();
  };
}

var robby = Robot.new();

@daybydae

John Chau
@ydjjabt
Aug 10 2015 05:32
@luishendrix92 u cannot do this
return new Robot; 
// new is for function only therefore u cannot use it on object
Dayne Wright
@daynewright
Aug 10 2015 05:33
@luishendrix92 Thanks for trying :) Appreciate the help so far. Have a great night
John Chau
@ydjjabt
Aug 10 2015 05:33
@luishendrix92 u cannot use function neither
lol
Dayne Wright
@daynewright
Aug 10 2015 05:33
tried this to no luck:
var Robot = {
     new: function(){
       return Robot.__proto__; 
    }  
};

var robby = Robot.new();
Luis Felipe López G.
@luishendrix92
Aug 10 2015 05:33
@Daynewr Did you try my last code? What did it return?
I used a constructor which lets new instances inherit, thus making Robot their prototype.
John Chau
@ydjjabt
Aug 10 2015 05:34
var Robot = {
     new: function(){
       return Robot.prototype;
// very wrong because Robot is an object..prototype only apply to function object 
    }  
};

var robby = Robot.new();
Dayne Wright
@daynewright
Aug 10 2015 05:34
ok..one sec
@ydjjabt Do you have a suggestion on how to solve it then?
John Chau
@ydjjabt
Aug 10 2015 05:35
@Daynewr up there
@Daynewr dont waste time and go for the answer and understand it lol
Dayne Wright
@daynewright
Aug 10 2015 05:37
@ydjjabt trying to find the answer so I can understand it. I am just hung up on how you complete this part “When Robot.new is called it should return a new object with Robot as its prototype "
John Chau
@ydjjabt
Aug 10 2015 05:37
i got it, i think
read ur last statement up there lol
Robert
@rc242
Aug 10 2015 05:38
@ahmeddin yes? I'm sure others here can answer your questions. A starting point for a solution would be to review this http://www.w3schools.com/js/js_properties.asp
Dayne Wright
@daynewright
Aug 10 2015 05:39
@ydjjabt I am lost I guess. The last thing I see is return Robot.protoype; which you state is not correct.
and it isn't
John Chau
@ydjjabt
Aug 10 2015 05:39
/*“When Robot.new is called it should return a new object with Robot as its prototype */ 
var Robot = {
     new: function(){
       return new new();

    }  
};

var robby = Robot.new();
Gary Meade
@garysmeade
Aug 10 2015 05:39
anyone here looked at the jQuery beta waypoints? I think I've found a problem here: http://beta.freecodecamp.com/challenges/waypoint-target-the-children-of-an-element-using-jquery and have posted a bug report.
refers to using children() to apply CSS to selected elements but there seems to be a discrepancy in the instructions....
John Chau
@ydjjabt
Aug 10 2015 05:41
@Daynewr did my last code work?
Dayne Wright
@daynewright
Aug 10 2015 05:41
no
✓ Submission results match expected

/home/ubuntu/workspace/070.js:9
       return new new(); 
                      ^
Error loading module: Unexpected token )
✗ Error loading module: Unexpected token )

# FAIL
John Chau
@ydjjabt
Aug 10 2015 05:42
var Robot = {
     new: function(){
       return new this;

    }  
};

var robby = Robot.new();
var Robot = {
     new: function(){
       return this;

    }  
};

var robby = Robot.new();
try both
Dayne Wright
@daynewright
Aug 10 2015 05:43
I have tried this but no luck
✓ Submission results match expected
✓ exports a Robot variable
✓ Robot.new is defined
✓ Robot.new is a function
✓ Robot.new returns an object
✗ Robot is the prototype of robby
I am missing something to make it a prototype of Robot within that method.
Woolwit
@Woolwit
Aug 10 2015 05:44
@garysmeade Child labor is frowned upon...
Mistereo
@Mistereo
Aug 10 2015 05:44
new this
John Chau
@ydjjabt
Aug 10 2015 05:44
@Daynewr u have the answer? lol
i want to see that beach ass answer
Robert Richey
@0x0936
Aug 10 2015 05:44
@Daynewr which nodeschool section is that in? I'd like to try it
it is planetproto
@luishendrix92 don’t have the answer…unless there is a way to get them prior to solving it.
Gary Meade
@garysmeade
Aug 10 2015 05:46
@Woolwit nice :)
Luis Felipe López G.
@luishendrix92
Aug 10 2015 05:48
@Daynewr I finally have the answer:
var Robot = {
    new: function () {
        return Object.create(this);
    }
}

var robby = Robot.new();
Mistereo
@Mistereo
Aug 10 2015 05:48
@Daynewr constructor should be a function not object.
Dayne Wright
@daynewright
Aug 10 2015 05:48
@luishendrix92 AH! yes…I should have known that.
thanks @luishendrix92
CamperBot
@camperbot
Aug 10 2015 05:49
daynewr sends brownie points to @luishendrix92 :sparkles: :thumbsup: :sparkles:
:star: 3 | @luishendrix92 | http://www.freecodecamp.com/luishendrix92
Luis Felipe López G.
@luishendrix92
Aug 10 2015 05:49
Seems like the syntax for that thing in ES5.1 is Object.create(proto [, propertiesObject ]) and the parameter is a prototype.
Dayne Wright
@daynewright
Aug 10 2015 05:50
yep..makes sense now
Mistereo
@Mistereo
Aug 10 2015 05:51
Is this not gonna work?
function Robot() {}
Robot.new = function () {
    return new this();
};
var robby = Robot.new();
Robert Richey
@0x0936
Aug 10 2015 05:56
@Mistereo that doesn't work. Robot needs to be an object literal. If you want to try for yourself, open a terminal and type npm install -g planetproto then run planetproto. This problem is 070.js
Mistereo
@Mistereo
Aug 10 2015 05:57
@0x0936 ok, sorry :)
Dayne Wright
@daynewright
Aug 10 2015 06:02
@Mistereo The next problem goes into contructors in that section on NodeSchool. :)
Randy Goldsmith
@Dueldrawer8
Aug 10 2015 06:06
var james = {
    job: "programmer",
    married: false,
    sayJob: function(job) {
        this.job
        console.log("Hi, I work as a" + " " + job);

    }
};

// james' first job
james.sayJob("scienist");

// change james' job to "super programmer" here
james.sayJob("super programmer");

// james' second job
james.sayJob("waiter");
im getting this message Oops, try again. It looks like your sayJob() method does not properly log
Robert Richey
@0x0936
Aug 10 2015 06:08
try this
sayJob: function(job) {
        console.log("Hi, I work as a" + " " + this.job);
}
Mistereo
@Mistereo
Aug 10 2015 06:08
@0x0936 then what the purpose of 'job' as param? :)
Randy Goldsmith
@Dueldrawer8
Aug 10 2015 06:08
Oops, try again. It looks like you did not change james.job to 'super programmer' on line 14.
theres link to problem
maybe that will help
Mistereo
@Mistereo
Aug 10 2015 06:09
@Dueldrawer8 try this:
sayJob: function(job) {
    this.job = job;
    console.log("Hi, I work as a" + " " + this.job);
}
nope..
I should read statements before suggest :)
Randy Goldsmith
@Dueldrawer8
Aug 10 2015 06:11
hmm.. someone told me its probably a bug
Robert Richey
@0x0936
Aug 10 2015 06:12
@Dueldrawer8 In addition to the above fix, also change the following line:
// change james' job to "super programmer" here
james.sayJob("super programmer"); // this code is not setting the job parameter

// fix
james.job = "super programmer";
Randy Goldsmith
@Dueldrawer8
Aug 10 2015 06:13
yeah someone said it was a bug.. whenever I changed the console.log to Console.log.. it said I got it right and turned green but gave an error message saying the console.log wasn't right.. basically
Robert Richey
@0x0936
Aug 10 2015 06:14
@Dueldrawer8 here is the complete solution:
var james = {
    job: "programmer",
    married: false,
    sayJob: function() {
        // complete this method
        console.log("Hi, I work as a " + this.job);
    }
};

// james' first job
james.sayJob();

// change james' job to "super programmer" here
james.job = "super programmer";

// james' second job
james.sayJob();
Randy Goldsmith
@Dueldrawer8
Aug 10 2015 06:16
ahh I see
thanks @0x0936
CamperBot
@camperbot
Aug 10 2015 06:17
dueldrawer8 sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
Robert Richey
@0x0936
Aug 10 2015 06:18
:)
Mahtab
@RoadToCode822
Aug 10 2015 06:19
can someone help me with bonfire palindrome
no one is up this late huh :/
Robert
@rc242
Aug 10 2015 06:21
@RoadToCode822 what's the question
Mahtab
@RoadToCode822
Aug 10 2015 06:27
function palindrome(str) {

  return str == str.split('').reverse().join('');
}



palindrome("eye");
thats my code and “race car” doesnt work so i’m wondering how to fix that
how do i remove space
Robert
@rc242
Aug 10 2015 06:28
bonfire palindrome
CamperBot
@camperbot
Aug 10 2015 06:28

:fire:Bonfire: Check for Palindromes :link:

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



palindrome("eye");

Return true if the given string is a palindrome. Otherwise, return false.
A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.
You'll need to remove punctuation and turn everything lower case in order to check for palindromes.
We'll pass strings with varying formats, such as "racecar", "RaceCar", and "race CAR" among others.
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 10 2015 06:30
@RoadToCode822 so, it appears if you modify your string to remove all of the extraneous characters, you'll have something to "compare". This is why you're having issues withe "race car"
Mahtab
@RoadToCode822
Aug 10 2015 06:31
sorry i don’t understan what you mean
understand*
what do you mean by compare
what would i compare?
Robert
@rc242
Aug 10 2015 06:32
In your conditional, you're comparing two strings.
Robert Richey
@0x0936
Aug 10 2015 06:32
@RoadToCode822 str.split(/\W/).reverse().join('') The regular expression passed to the split function will match any non-alphanumeric character and non-underscore
that's one way to get rid of spaces and punctuation from a string
Mahtab
@RoadToCode822
Aug 10 2015 06:34
one way in regex?
more ways to do it using regex right
Robert Richey
@0x0936
Aug 10 2015 06:35
sure. there are almost always more than one way of doing anything
Robert
@rc242
Aug 10 2015 06:36
sure.
Robert Richey
@0x0936
Aug 10 2015 06:37
str.split(/[ ,.]/).join('') here is another way, explicitly removing spaces, commas and periods from a string.
Robert
@rc242
Aug 10 2015 06:38
@RoadToCode822 I'm not sure if that bonfire wants you to ignore underscores, too.
Robert Richey
@0x0936
Aug 10 2015 06:38
@rc242 I tested it. /\W/ works.
Mahtab
@RoadToCode822
Aug 10 2015 06:38
is \w equivalent to [A-Za-z0-9_]
Robert Richey
@0x0936
Aug 10 2015 06:39
yes
Robert
@rc242
Aug 10 2015 06:39
...
Mahtab
@RoadToCode822
Aug 10 2015 06:39
whats the difference between /\w/ and /\W/
Robert Richey
@0x0936
Aug 10 2015 06:39
\W is equivalent to non-alphanumeric characters, and no underscore
it's the inverse
Robert
@rc242
Aug 10 2015 06:40
other way around.
Mahtab
@RoadToCode822
Aug 10 2015 06:40
I see, so \w/ is alphanumeric characters, including underscore?
Robert
@rc242
Aug 10 2015 06:40
@RoadToCode822 if you want to use just alpha, just do /[^A-Za-z]/
Robert Richey
@0x0936
Aug 10 2015 06:41
@RoadToCode822 yes
Robert
@rc242
Aug 10 2015 06:41
@RoadToCode822 I would expect that bonfire to use dashes before it uses underscores.
Mahtab
@RoadToCode822
Aug 10 2015 06:42
i know regex is important, whats the best way to learn it? Should I sit down and try to memorize or what
Robert Richey
@0x0936
Aug 10 2015 06:43
you'll learn about them in this waypoint
the big picture is if you're doing string manipulation, regex is your best friend
Mahtab
@RoadToCode822
Aug 10 2015 06:43
I did that one already but I guess i have to keep doing it?
Robert Richey
@0x0936
Aug 10 2015 06:43
it avoids complicated looping
jb299
@jb299
Aug 10 2015 06:44
Screenhero invite?
Robert
@rc242
Aug 10 2015 06:45
@RoadToCode822 You'll get more practice through the bonfires.
Robert Richey
@0x0936
Aug 10 2015 06:46
@RoadToCode822 if you've gone through all the regex stuff, check out this video. It's a fast 48 minutes, but should help solidify the concepts.
Dayne Wright
@daynewright
Aug 10 2015 06:46
@0x0936 Can you help me with this last bit?
// -> Define a 'Robot' function constructor
// -> Create two instances of Robot: 'robby' and 'cranky'
// -> Both robby and cranky should respond to 'parts' and 'capabilities', these 
//    should be empty arrays at first

function Robot() {
    this.parts = [];
    this.capabilities = [];
}

var robby = new Robot();
var cranky = new Robot();

// -> Add 'core' to robby.parts, cranky.parts should still be empty
// -> Add 'fly' to robby.capabilities, after doing that cranky.capabilities must 
//    also have 'fly' without adding to it directly, so this property has to be 
//    shared

robby.parts.push('core');
Robot.prototype.capabilities = ['fly’];
Mahtab
@RoadToCode822
Aug 10 2015 06:48
Also, before I send this solution, I wanted to ask some fundamental questions that I think will help clarify these challenges a lot more:
why is RaceCar invalid?
RaceCar when reversed = raCecaR
which is essentially racecar
Luis Felipe López G.
@luishendrix92
Aug 10 2015 06:49
@RoadToCode822 Mabe you should lowercase everything
Dayne Wright
@daynewright
Aug 10 2015 06:49
@RoadToCode822 If I remember correctly it wants lowercase
Mahtab
@RoadToCode822
Aug 10 2015 06:49
yes but why does it want lowercase?
Robert Richey
@0x0936
Aug 10 2015 06:50
@Daynewr without doing the challenge yet, it looks like this.capabilities should be added to the prototype so that all Robot objects share the property
Robert
@rc242
Aug 10 2015 06:50
@RoadToCode822 because it's a requirement in the bonfire that a palindrome is case-insensitive.
bonfire palindrome
CamperBot
@camperbot
Aug 10 2015 06:50

:fire:Bonfire: Check for Palindromes :link:

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



palindrome("eye");

Return true if the given string is a palindrome. Otherwise, return false.
A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.
You'll need to remove punctuation and turn everything lower case in order to check for palindromes.
We'll pass strings with varying formats, such as "racecar", "RaceCar", and "race CAR" among others.
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 10 2015 06:50
@RoadToCode822 Because "C" === "c" returns false, why? Because the unicode of C and c are different.
Mahtab
@RoadToCode822
Aug 10 2015 06:50
oh ok thanks @rc242
ohhh, makes sense @luishendrix92, thanks!
Robert Richey
@0x0936
Aug 10 2015 06:51
@Daynewr
function Robot() {
    this.parts = [];    
}

Robot.prototype.capabilities = []; // this property will now be shared among all Robot objects
Dayne Wright
@daynewright
Aug 10 2015 06:52
ah.. I think I remember now.
Mahtab
@RoadToCode822
Aug 10 2015 06:52
Damn ya’ll are some smart ass people :) so refreshing :D
Dayne Wright
@daynewright
Aug 10 2015 06:53
thanks @0x0936
CamperBot
@camperbot
Aug 10 2015 06:53
daynewr sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
Robert Richey
@0x0936
Aug 10 2015 06:54
glad I could help :)
Dayne Wright
@daynewright
Aug 10 2015 06:54
Ok…goodnight all. Thanks for all the help! I will have to review all this OOP javascript stuff tomorrow to see how much stayed there :)
Mahtab
@RoadToCode822
Aug 10 2015 06:56

Fellas, some issues here:

```

  function palindrome(str) {

    return str == str.split(/\W/).reverse().join('');
  }

  palindrome("eye");
Robert Richey
@0x0936
Aug 10 2015 06:56
Good night @Daynewr
Mahtab
@RoadToCode822
Aug 10 2015 06:57
I tried that, and i get a bunch of errors:
assert.deepEqual(palindrome("race car"), true);expected false to deeply equal true
assert.deepEqual(palindrome("A man, a plan, a canal. Panama"), true);expected false to deeply equal true
assert.deepEqual(palindrome("never odd or even"), true);expected false to deeply equal true
assert.deepEqual(palindrome("nope"), false);expected true to deeply equal false
Robert Richey
@0x0936
Aug 10 2015 06:58
function palindrome(str) {
  // lowercase str
  str = str.split(/\W/).join('');

  // rest of logic

  // return something
}
your code is just the first part of the solution. it is lowercasing the incoming string
while removing spaces and punctuation
Luis Felipe López G.
@luishendrix92
Aug 10 2015 07:00

@RoadToCode822 I had this solution for that bonfire:

function palindrome(str) {
  var cleanStr = str.toLowerCase().split(/\W/).join('');
  function rev(str) { return str.split('').reverse().join(''); }

  return cleanStr === rev(cleanStr);
}

palindrome("eye");

And if you don't whant the function in there you could type:

function palindrome(str) {
  var cleanStr = str.toLowerCase().split(/\W/).join('');

  return cleanStr === cleanStr.split('').reverse().join('');
}

palindrome("eye");
I think it's more readable to say oh well, return the result of comparing the original string CLEANED (with only alphanumeric characters) and that very cleaned string but reversed.
Mahtab
@RoadToCode822
Aug 10 2015 07:02
is that what you did with the first set of code?
Luis Felipe López G.
@luishendrix92
Aug 10 2015 07:03
@RoadToCode822 Those two sets are the same thing, but I wrapped the part of reversing the cleaned string in a function in order to make it more understandable. The function rev(str) reverses a string.
Remember a palindrome is when reading something from left to right and right to left is the same thing.
To be honest I didn't know you could use a RegExp in the Split() method lol, I used the String.prototype.replace() method to avoid using a Join method twice.
Mahtab
@RoadToCode822
Aug 10 2015 07:07
This message was deleted
This message was deleted
This message was deleted
  function palindrome(str) {

    var cleanStr = str.toLowerCase().split(/W/).join('');
    cleanStr = str.reverse().join('');

    return true;
  }

  palindrome("eye");
After trying this code, I get the following error:
Robert
@rc242
Aug 10 2015 07:08
@RoadToCode822 I'm going to give you a hint. You don't need to use a split, join, or reverse.
Mahtab
@RoadToCode822
Aug 10 2015 07:08
Program Execution FailureNo user tests were run.
Robert Richey
@0x0936
Aug 10 2015 07:10
@rc242 you've peaked my interest. I have no idea how to solve that without split, join, reverse - without complicated looping.
Matthew Barber
@Honno
Aug 10 2015 07:10
Hey, need help with bonfire pairwise
bonfire pairwise
CamperBot
@camperbot
Aug 10 2015 07:10
Sorry, can't find a bonfire called pairwise. [ Check the map? ]
Robert
@rc242
Aug 10 2015 07:10
@RoadToCode822 if you insist on doing either, you need two strings. One for the non reversed string and one for the reversed string.
Matthew Barber
@Honno
Aug 10 2015 07:10
ok, w/e, it asks "Return the sum of all indices of elements of 'arr' that can be paired with one other element to form a sum that equals the value in the second argument 'arg'. If multiple sums are possible, return the smallest sum. Once an element has been used, it cannot be reused to pair with another."
what does it mean by the smallest sum?
this doesn't get the right answer http://pastebin.com/MYFf5yVT
"For example, pairwise([1, 4, 2, 3, 0, 5], 7) should return 11 because 4, 2, 3 and 5 can be paired with each other to equal 7"
that's not using the lowest sum?
Mahtab
@RoadToCode822
Aug 10 2015 07:12
can you elaborate on what you mean @rc242
Matthew Barber
@Honno
Aug 10 2015 07:12
@RoadToCode822 A command which replaces a RegEx objec t in a string
Mahtab
@RoadToCode822
Aug 10 2015 07:13
im pretty confused
he said "you need two strings. One for the non reversed string and one for the reversed string."
Robert
@rc242
Aug 10 2015 07:13
@RoadToCode822 You have two strings. One string is lower case, alphanumeric with underscores, and the other will need to be the reverse of that string.
Mahtab
@RoadToCode822
Aug 10 2015 07:13
i dont know how to translate that into code
right ok let me try that
Bernard Pagoaga
@BPagoaga
Aug 10 2015 07:15
Hello, any hint for this one ? http://www.freecodecamp.com/challenges/bonfire-where-art-thou
function where(collection, source) {
  var arr = [];
  // What's in a name?
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
Robert
@rc242
Aug 10 2015 07:15
@0x0936 complicated for loops? not really.
thereotically speaking, you don't even need replace.
Mahtab
@RoadToCode822
Aug 10 2015 07:16
This message was deleted
  function palindrome(str) {

    var cleanStr = str.toLowerCase().split(/W/).join('');
    return str == cleanStr.reverse().join('');
  }

  palindrome("eye");
still same error
" One string is lower case, alphanumeric with underscores, and the other will need to be the reverse of that string."
Robert
@rc242
Aug 10 2015 07:17
@RoadToCode822 You can't compare against the str method variable.
Mahtab
@RoadToCode822
Aug 10 2015 07:17
i cant do str ==?
Robert
@rc242
Aug 10 2015 07:18
The variable str is the original string. It has all sorts of invalid characters in it.
Matthew Barber
@Honno
Aug 10 2015 07:18
@RoadToCode822
var strClean = str.toLowerCase().replace(/\W/g, "").replace(/,/g, "").replace(/\./g, "");
then, you can reverse strClean maybe?
Mahtab
@RoadToCode822
Aug 10 2015 07:19
your code seems very complicated @Honno
Matthew Barber
@Honno
Aug 10 2015 07:19
then you can do a strict equals on the cleaned string and the reverse of it ===
Mahtab
@RoadToCode822
Aug 10 2015 07:19
i see what you mean @rc242 let me pick at it a little bit more then
Robert
@rc242
Aug 10 2015 07:19
No really complicated. Just unneeded code.
Luis Felipe López G.
@luishendrix92
Aug 10 2015 07:19
@RoadToCode822 Remember, in order to reverse a string you have to use the split method because reverse() is for arrays.
Matthew Barber
@Honno
Aug 10 2015 07:19
ahh @RoadToCode822, you know RegEx?
basically what I'm doing is replacing whiteplaces, commas and dots with nothing
*whitespaces
wait...
Robert
@rc242
Aug 10 2015 07:20
@Honno : that' s fine, but you could also do that with \W.
Mahtab
@RoadToCode822
Aug 10 2015 07:20
  function palindrome(str) {

    var cleanStr = str.toLowerCase().split(/W/).join('');
    var anotherStr = cleanStr.reverse().join('');
    return cleanStr == anotherStr;
  }
  palindrome("eye");
Luis Felipe López G.
@luishendrix92
Aug 10 2015 07:20
@Honno Try this: /\W/g
Matthew Barber
@Honno
Aug 10 2015 07:20
yeah \W is any non alphanumeric character sorry
forgot lol
\s is whitespace
Mahtab
@RoadToCode822
Aug 10 2015 07:21
not working
Matthew Barber
@Honno
Aug 10 2015 07:21
@RoadToCode822 you need to make the string an array first to reverse
oh wait
Mahtab
@RoadToCode822
Aug 10 2015 07:21
doesn’t split do that
Matthew Barber
@Honno
Aug 10 2015 07:22
you need to do /\W/g
because
\ means it's not a capital w
/g means it's repetitive
not just the first one it finds
\W is any non-alphanumeric character
/g is a mutator so goes after the /whatever/here
Luis Felipe López G.
@luishendrix92
Aug 10 2015 07:23
@RoadToCode822 YOu're very close, try this:
  function palindrome(str) {

    var original= str.toLowerCase().replace(/\W/g, '');
    var reversed= original.split('').reverse().join('');
    return original == reversed;
  }
  palindrome("eye");
Mahtab
@RoadToCode822
Aug 10 2015 07:23
whats the purpose of /g
Matthew Barber
@Honno
Aug 10 2015 07:23
sorry I'm learning to was a bit confused ;p;
@RoadToCode822 So it doesn't split on the first \W, but all \W
Robert
@rc242
Aug 10 2015 07:23
it'll split on every \W match.
Mahtab
@RoadToCode822
Aug 10 2015 07:24
i understand that code minus the regex
Robert
@rc242
Aug 10 2015 07:24
you don't need the g.
Mahtab
@RoadToCode822
Aug 10 2015 07:24
/ - stands for what?
\ - stands for what?
W - non-alphanumeric and no underscores?
/ - stand for what?
g - stand for waht?
Nick Hu
@nicholashu
Aug 10 2015 07:25
Hey, does $.getJSON call the API everytime the function is run or only once per page load?
Matthew Barber
@Honno
Aug 10 2015 07:25
oh I didn't know that haha, screw me today @rc242
@RoadToCode822 you have learnt RegEx right?
@RoadToCode822 in JS
/ - starts RegEx input
\ - a breaker, so it can take special values, e.g. \. is a dot, \s is a whitespace
W - is capital w, W
\W - is any non-alphanumeric character
/ - ends RegEx input
g - is a mutator to the RegEx input
a mutator that uh
global?
anyway I need a break, this pairwise exercise is killing me
Chocobowings
@chocobowings
Aug 10 2015 07:28
@RoadToCode822 in regex g is to do a "global" search
Mahtab
@RoadToCode822
Aug 10 2015 07:28
This message was deleted
  function palindrome(str) {

    var cleanStr = str.toLowerCase().replace(/\W/g, '');
    var anotherStr = cleanStr.split().reverse().join('');
    return cleanStr == anotherStr;


  }

  palindrome("eye");
no luck
Matthew Barber
@Honno
Aug 10 2015 07:29
@RoadToCode822 need to split("")
Sophanarith Sok
@sok213
Aug 10 2015 07:29
@RoadToCode822 You can read all bout the regex characters and meanings here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
Luis Felipe López G.
@luishendrix92
Aug 10 2015 07:29
@RoadToCode822 Check at your code I modified, with using .replace() you don't need to split it and join it again!
/ is the beginning and the end of your regular expression, you can follow it with g m and i which are called flags.
\ is an escape character, there are characters reserved for the Regular Expression engine such as []/.*()|\ and if you want to consider those in your pattern you need to escape them with \
\W is the same as \w but reversed, which means NOT an alphanumeric character, it's the same of \S and \D and they stand for "NOT whitespace" and "NOT a digit" respectively.
g i and m are flags that go after the / ending onf your regex; i means case-insensitive, g means global (has every match in consideration instead of the first one) and m is for multiline strings.
Matthew Barber
@Honno
Aug 10 2015 07:29
@RoadToCode822 so it splits whenever it meets "", or, between any character
Mahtab
@RoadToCode822
Aug 10 2015 07:29
ahhh
thanks
finally
thanks honno
Matthew Barber
@Honno
Aug 10 2015 07:30
yeah @RoadToCode822 take note what @luishendrix92 said and complete the regexone.com tutorial fully
Robert
@rc242
Aug 10 2015 07:31
@0x0936 if you're still interested in what I did,
function palindrome(str) {
  var s = str.toLowerCase().replace(/[^a-zA-Z]+/g,'');

  for (i = 0, j = s.length - 1; i < j; i++, j--) {
    if (s[i] != s[j]) return false;

  }
  return true;
}
Matthew Barber
@Honno
Aug 10 2015 07:31
@rc242 same thing as doing a strict equals really, just more elitist? :p
more effecient sure
Robert
@rc242
Aug 10 2015 07:32
if it's more efficient, i fail to see how that's elitist.
Mahtab
@RoadToCode822
Aug 10 2015 07:33
out of curiosity, @rc242 , how does your code work
Matthew Barber
@Honno
Aug 10 2015 07:33
@rc242 just a joke, a lot of linux neckbeards types refuse to use inbuilt functions and stick to iterations only to do their work for maximum efficiency heh
Mahtab
@RoadToCode822
Aug 10 2015 07:33
more specifically, the for loop and the conditional
Nick Hu
@nicholashu
Aug 10 2015 07:34
can someone tell me why my API calls bring back the same random quote every time? http://codepen.io/nicholashu/pen/PqVgLe
Robert
@rc242
Aug 10 2015 07:34
@RoadToCode822 it generates one string that has no invalid characters, and then compares two indexes until those two indexes are equal.
if they're equal, they're the same character and no need to compare other characters.
with that, i'm going to bed. past my bedtime.
Mahtab
@RoadToCode822
Aug 10 2015 07:37
thanks man have a gnight
Luis Felipe López G.
@luishendrix92
Aug 10 2015 07:37
@rc242 It's close to my first solution, I had two pointers, one at the end and one at the beginning but I had forgot that you can declare two pointers inside a for loop and I did a mess, the code worked tho.
Matthew Barber
@Honno
Aug 10 2015 08:14
Someone please show me their bonfire pairwise solution heh
I've been working on it for 2 hours, I can't look at code anymore
Now when I try to recreate it I'm going to die
If I don't complete this my FCC life is over
ITS UP TO YOU TO SAVE ME
in the end it spiralled into madness http://pastebin.com/CmKaWZD2
I want to see an effecient solution for the basic stuff as well as the sum checking
Mistereo
@Mistereo
Aug 10 2015 08:17
@Honno sometimes it's better to start from the beginning :)
Matthew Barber
@Honno
Aug 10 2015 08:17
@Mistereo Yeah I've done that a few times and I just don't want to recreate a really lengthy part which I'm sure some inbuilt js functions could do in a line or something
Mistereo
@Mistereo
Aug 10 2015 08:18
I can try to help you at floobits or something similar :) @Honno
@Honno it's better then just copy/paste the answer I think :)
Matthew Barber
@Honno
Aug 10 2015 08:19
@Mistereo Thanks for the offer but I first need to clean up my existing code
Yeah I know, I do make the effort to understand the answers though
Mistereo
@Mistereo
Aug 10 2015 08:20
@Honno we can start from function pairwise() {}
Matthew Barber
@Honno
Aug 10 2015 08:20
... you'd do that? for me? @Mistereo
Lindell C. Bailey
@SamusBailey
Aug 10 2015 08:39
nGUYS HOW DO YOU STAY FOCUSED WHEN CODING AND ANY POINTERS LOL not (->,int,int ptr,) kind of pointers
Sorry for caps
:/
they wouldnt let me add the astricks for the pointers :( but i was refering to pointers in C++
Tristanto
@rustyworks
Aug 10 2015 08:42
"When I am programming, I am at a nexus. My thoughts become concrete. My ideas transform illusion into reality. The structure of existence is remade before my very eyes. I become a vessel for the creative force of the universe. I am carried aloft as if on the wings of dragons." - James Geofrey (Computer Parables)
John Chau
@ydjjabt
Aug 10 2015 08:42
@SamusBailey lol good one c++
c++ is really dope. one day i will study them
but javascript got functional programming, real cool dope
Tristanto
@rustyworks
Aug 10 2015 08:43
What kind of distraction ? If it a noise, you should block it with brown noise
If it an email or sms, use DND mode
Lindell C. Bailey
@SamusBailey
Aug 10 2015 08:45
whats brown noise like a sound machine
Tristanto
@rustyworks
Aug 10 2015 08:46
No, just like a broken television sound. But its block chattering sound, and other.
Oops, sorry for the thumbnails :-s
Lindell C. Bailey
@SamusBailey
Aug 10 2015 08:47
oh my sweeet marry mother of Goodness this is so beautiful thank you
spild i listen to this all the time or only when im studying
should i put this on cd and play it on my radio?
Jose Gonzalez
@sneezyxl
Aug 10 2015 08:48
@rustyworks Just jump into the channel thanks for the share will definietly try this out.
Tristanto
@rustyworks
Aug 10 2015 08:48
@SamusBailey ywc, if you like the "pay" noise, you can search pure white noise in internet. And if you like the instrument music, you can hear relaxdaily channel on youtube
Err.. I hear it online :D
Matthew Barber
@Honno
Aug 10 2015 08:49
@Mistereo I understand why you wanted to pair program instead of just give a solution
thanks @Mistereo, the true MVP
CamperBot
@camperbot
Aug 10 2015 08:49
honno sends brownie points to @mistereo :sparkles: :thumbsup: :sparkles:
John Chau
@ydjjabt
Aug 10 2015 08:51
@Honno what MVP? lol
Matthew Barber
@Honno
Aug 10 2015 08:51
He's the MVP of the FCC to the GGWP
Tristanto
@rustyworks
Aug 10 2015 08:52
@Honno Are you DotA player :D GGWP
Matthew Barber
@Honno
Aug 10 2015 08:52
@rustyworks nah, just played games
@rustyworks until I found FCC
John Chau
@ydjjabt
Aug 10 2015 08:55
@Honno
unction repeat(str, num) {
  // repeat after me
  return str;
}

repeat('abc', 3);
@Honno
function pairwise(arr, arg) {
var match = [];
for(var i = 0; i < arr.length - 1; i ++){
    for(var j = i+ 1; j < arr.length; j++){

        if(arr[i] + arr[j] == arg)
        {
            match.push(j)
            var getI = true;
            arr.splice(j,1,undefined);
            break;

        }
    }

    if(getI ){
        match.push(i)
        getI = false;
    }

}
return match.reduce(function(acc,current){return  acc + current},0)

}
pairwise([1,4,2,3,0,5], 7);
Matthew Barber
@Honno
Aug 10 2015 08:55
hmm @ydjjabt ?
oooh
I see I see
Same thing essentially
function pairwise(arr, arg) {
  var used = {};
  var sum = 0;
  for(var i = 0; i < arr.length; i++) { 
    if (used[i]) continue;
    for(var j = 0; j < arr.length; j++) {
      if(arr[i] + arr[j] === arg && i !== j) {
        if(used[j]) continue;
        sum += i + j;
        used[i] = true;
        used[j] = true;
        break;
      }
    } 
  }
  return sum;
}
John Chau
@ydjjabt
Aug 10 2015 08:56
@Honno can i be MVP too?
@Honno lesson is for array must remember splice and slice lol
Matthew Barber
@Honno
Aug 10 2015 08:57
haha @ydjjabt , @Mistereo actually pair programmed with me and taught me everything by making me think
John Chau
@ydjjabt
Aug 10 2015 08:57
dude i need mistereo help in future soon for the tic tac toe or calculator
lol
Matthew Barber
@Honno
Aug 10 2015 08:57
oh @ydjjabt, I spent an hour struggling on splicing and slicing, I didn't realize it affected the original array too haha
John Chau
@ydjjabt
Aug 10 2015 08:57
the pain is the html/javascript and jquery connection, it spin me in circle
Matthew Barber
@Honno
Aug 10 2015 08:58
because I didn't know anything on shallow vs deep copying
John Chau
@ydjjabt
Aug 10 2015 08:58
splice(index,number to delete, item to insert)
and splice mutate
shallow deep copying? i have no idea
splice affect original array
slice doesnt
splice and slice get rid of lot of headache
Matthew Barber
@Honno
Aug 10 2015 08:59

yeah @ydjjabt, when you do

var value2 = value;

If you change value, value2 is affected, and visa versa

And I didn't know that, was actually just using splice, thought slice was the oppisite
the more you learn uggh
OK TIME TO STOP LOOKING AT THIS SCREEN
John Chau
@ydjjabt
Aug 10 2015 08:59
slice is a slice of an array
and that slice is copy of the slice of that array
splice can delete only, or insert only, or delete and insert.....very powerful
splice will change/affect ur original array whereas slice doesnt
look at my code, it short because of that
Jacob Jamell
@jjamell
Aug 10 2015 09:00
I hate that particular quirk of Javascript. Primitives pass by value, objects pass by reference. You have to know ahead of time if the var is a primitive or object to predict what will happen
I just avoid it altogether by using method chains and return object because returns are always copied and not referenced
Mistereo
@Mistereo
Aug 10 2015 09:06
@jjamell it's not true. Check this:
function foo(arg) {
  return arg;
}
var arr = [1, 2, 3];
var arr2 = foo(arr);

arr2[0] = 42;
// Both arr and arr2 now [42, 2, 3]
Jacob Jamell
@jjamell
Aug 10 2015 09:09
makes sense. arr was defined outside of foo, thus breaking closure and allowing return arg; to become a reference
I think. Ugh.
Mistereo
@Mistereo
Aug 10 2015 09:10
it's not depends on where arr is defined.
Jacob Jamell
@jjamell
Aug 10 2015 09:13
@Mistereo please explain how to avoid this. :fearful:
Tristanto
@rustyworks
Aug 10 2015 09:15
@jjamell Thats common on all language, all array are mutable and pass by reference not by value
Mistereo
@Mistereo
Aug 10 2015 09:15
@jjamell objects in javascript are always passed/returned by reference.
Tristanto
@rustyworks
Aug 10 2015 09:15
^That
Mistereo
@Mistereo
Aug 10 2015 09:15
@jjamell array is an object, so...
Tristanto
@rustyworks
Aug 10 2015 09:16
Do manual array copy :D
var a = [1, 2, 3];
var b = a.map(Number);
Mistereo
@Mistereo
Aug 10 2015 09:17
@rustyworks
var a = [1, 2, 3];
var b = a.slice();
Jacob Jamell
@jjamell
Aug 10 2015 09:18
Ok, so if I do anything to an array that returns a new modified array, will that be sufficient to avoid pass by reference?
Mistereo
@Mistereo
Aug 10 2015 09:18
@jjamell
Tristanto
@rustyworks
Aug 10 2015 09:19
Ah ... Thats better :D
@Mistereo Does it include deep copy (I mean nested array)
Mistereo
@Mistereo
Aug 10 2015 09:20
@jjamell you can use a method that returns reference to cloned (and modified) array. foo can be changed to:
function foo(arg) {
    return arg.slice();
}
@rustyworks nope.
Jacob Jamell
@jjamell
Aug 10 2015 09:23
If it's a nested aray, it will become an array of references. Which means changing the any array inside will modify it in the original nested array. Right?
Mistereo
@Mistereo
Aug 10 2015 09:23
@jjamell also methods like .map .filter and so on don't modify the original array, but return a ref to a new.
Matthew Barber
@Honno
Aug 10 2015 09:23
@jjamell haha it was so confusing, because I did simple python scripts before and thought assignments were always copies, at least taught me a new HOW in how programming languages differ
Tristanto
@rustyworks
Aug 10 2015 09:24
@Honno No, Python also treat array as reference
MD MOJIBUL HOQUE
@Mojibul
Aug 10 2015 09:24
Hi JS expert I need your help ... Your method failed when sideLength was 0 where it returned NaN instead of 0
Tristanto
@rustyworks
Aug 10 2015 09:24
You need import copy.deepcopy :D
Matthew Barber
@Honno
Aug 10 2015 09:24
wait does it
MD MOJIBUL HOQUE
@Mojibul
Aug 10 2015 09:24
I get this message when i submit
Matthew Barber
@Honno
Aug 10 2015 09:24
I haven't touched it in ages
Jacob Jamell
@jjamell
Aug 10 2015 09:24
@Mistereo so it's still a reference, just to a new array instead of the old one. Good enough.
Matthew Barber
@Honno
Aug 10 2015 09:24
Ah well, now I know I'm an idiot too
Mistereo
@Mistereo
Aug 10 2015 09:24
@jjamell yes, still ref.
Tristanto
@rustyworks
Aug 10 2015 09:24
@Honno all mutable in python :D
MD MOJIBUL HOQUE
@Mojibul
Aug 10 2015 09:25
Introduction to Objects I 19/33 . I stuck on this. please help me.
Matthew Barber
@Honno
Aug 10 2015 09:25
what does mutable mean in that sense @rustyworks ?
Tristanto
@rustyworks
Aug 10 2015 09:26
It means, it can grow, shrink, or mutate without creating new object
MD MOJIBUL HOQUE
@Mojibul
Aug 10 2015 09:26
Any body there who help me ?
I'm stuck on Introduction to Objects I 19/33 . I stuck on this. please help me.
Matthew Barber
@Honno
Aug 10 2015 09:26
Ah thanks @rustyworks
Waut a sec @Mojibul
MD MOJIBUL HOQUE
@Mojibul
Aug 10 2015 09:26
var square = new Object();
square.sideLength = 6;
square.calcPerimeter = function() {
return this.sideLength 4;
};
// help us define an area method here
square.calcArea = function(){
return (this.sidelength
this.sidelength);
};
var p = square.calcPerimeter();
var a = square.calcArea();
Tristanto
@rustyworks
Aug 10 2015 09:26
for example:
a = [1, 2, 3]
a[0] = 42;
a = [42, 2, 3]; <- without creating new object
MD MOJIBUL HOQUE
@Mojibul
Aug 10 2015 09:27
Thanks Honno. I need your help.
Matthew Barber
@Honno
Aug 10 2015 09:27

@Mojibul Display it as code, e.g.:
```

<insert code>
```

MD MOJIBUL HOQUE
@Mojibul
Aug 10 2015 09:27
'''
var square = new Object();
square.sideLength = 6;
square.calcPerimeter = function() {
return this.sideLength 4;
};
// help us define an area method here
square.calcArea = function(){
return (this.sidelength
this.sidelength);
};
var p = square.calcPerimeter();
var a = square.calcArea();
'''
Matthew Barber
@Honno
Aug 10 2015 09:28
No, `, which is below your esc
Tristanto
@rustyworks
Aug 10 2015 09:28
if immutable:
a = (1, 2, 3) <- I use tuple
a = a[0] + a[:-1]
creating (1, ) + (2, 3)
So all is 3 objects
Matthew Barber
@Honno
Aug 10 2015 09:28
Also use shift enter
MD MOJIBUL HOQUE
@Mojibul
Aug 10 2015 09:28
var square = new Object();
square.sideLength = 6;
square.calcPerimeter = function() {
  return this.sideLength * 4;
};
// help us define an area method here
square.calcArea = function(){
    return  (this.sidelength * this.sidelength);
    };
var p = square.calcPerimeter();
var a = square.calcArea();
Matthew Barber
@Honno
Aug 10 2015 09:28
Ok, @Mojibul, whats the error?
should work...
MD MOJIBUL HOQUE
@Mojibul
Aug 10 2015 09:29
When i submit show Your method failed when sideLength was 0 where it returned NaN instead of 0
this messge
Honno do you understand the error.
Tristanto
@rustyworks
Aug 10 2015 09:29
This message was deleted
Err... wait
Mistereo
@Mistereo
Aug 10 2015 09:30
@Mojibul give me a link to this lesson.
Mistereo check this link.
Mistereo
@Mistereo
Aug 10 2015 09:31
@Mojibul in your calcArea is a typo.
Tristanto
@rustyworks
Aug 10 2015 09:31
sidelength
Matthew Barber
@Honno
Aug 10 2015 09:31
oooh
Tristanto
@rustyworks
Aug 10 2015 09:31
it should sideLength
Matthew Barber
@Honno
Aug 10 2015 09:31
lmao
Tristanto
@rustyworks
Aug 10 2015 09:31
x_X
Matthew Barber
@Honno
Aug 10 2015 09:31
ugh I wanted to be the harbinger of truth @rustyworks , but no I'm the dumb kid who can't pairwise
back to functional programming wooo
I really want to do some front end work soon heh
just something pretty for a change
Tristanto
@rustyworks
Aug 10 2015 09:32
:(
MD MOJIBUL HOQUE
@Mojibul
Aug 10 2015 09:32
Thanks a lot rustyworks. Javascript is a case sensitive language.
Quincy Larson
@ilovejavascript
Aug 10 2015 09:33
This message was deleted
Matthew Barber
@Honno
Aug 10 2015 09:34
@ilovejavascript ITS THE MAN HIMSELF
and he deleted his message
what did he say
who knows
find out next time in
CamperBot
@camperbot
Aug 10 2015 09:34
find out next time in
nothing found
Matthew Barber
@Honno
Aug 10 2015 09:34
well screw you camperbot
(if quincy were to ever read this, THANK YOU)
Tristanto
@rustyworks
Aug 10 2015 09:36
No, all is true, but ilovejavascript just for video tutorial purpose
Matthew Barber
@Honno
Aug 10 2015 09:37
oh it's a bot, cool
Mistereo
@Mistereo
Aug 10 2015 09:41
find me
Mistereo
@Mistereo
Aug 10 2015 09:41
find Mistereo
CamperBot
@camperbot
Aug 10 2015 09:41
find mistereo
nothing found
jb299
@jb299
Aug 10 2015 09:43
function convert(str){
  var destroy = [
    {str:'&amp;'},
    {str: '&lt;'},
    {str: '&gt;'},
    {str: '&qout;'},
    {str: '&apos;'}
  ];
  var change = str;
  for (i=0; i < destroy.length; i++){
    change = change.replace(destroy[i].re,destroy[i].str);
  }
  return change;
}
convert('Dolce & Gabbana');
help?
CamperBot
@camperbot
Aug 10 2015 09:43

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

Basic commands:

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

:unlock: More commands and info

:pencil: read more about camperbot on the FCC Wiki

Matthew Barber
@Honno
Aug 10 2015 09:43
@jb299 what bonfire is that?
CamperBot
@camperbot
Aug 10 2015 09:43
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
jb299
@jb299
Aug 10 2015 09:44
28
Matthew Barber
@Honno
Aug 10 2015 09:44
ah bonfire convert html
CamperBot
@camperbot
Aug 10 2015 09:44
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Mistereo
@Mistereo
Aug 10 2015 09:44
@camperbot take it easy :)
jb299
@jb299
Aug 10 2015 09:45
Think i missed some code.
Matthew Barber
@Honno
Aug 10 2015 09:45
@jb299 What does destroy[i].re refer to?
Mistereo
@Mistereo
Aug 10 2015 09:46
@jb299 what is destroy[i].re in your code? Seems like it's not defined.
change = change.replace(destroy[i].re,destroy[i].str);
jb299
@jb299
Aug 10 2015 09:50
@Mistereo thats what i forgot to put in var destroy .re
MD MOJIBUL HOQUE
@Mojibul
Aug 10 2015 09:51
function Person(name,age) {
  this.name = name;
  this.age = age;
  this.species = "Homo Sapiens";
};

var sally = Person("Sally Bowles",39); 
var holden = Person("Holden Caulfield" ,16);
console.log("sally's species is " + sally.species + " and she is " + sally.age);
console.log("holden's species is " + holden.species + " and he is " + holden.age);
jb299
@jb299
Aug 10 2015 09:51
[re: &, str: '&']
MD MOJIBUL HOQUE
@Mojibul
Aug 10 2015 09:51
What's problem here.
I can't find out the bug.
Please help me.
Mistereo
@Mistereo
Aug 10 2015 09:52
@Mojibul probably forget about new.
@Mojibul new Person(...)
MD MOJIBUL HOQUE
@Mojibul
Aug 10 2015 09:52
Mistereo Thanks a lot .
You are right
You have good knowledge on JS.
There is no doubt .
Jonathan
@jonjitsu
Aug 10 2015 09:58
Anyone tried the twitch api with emacs restclient-mode? I get a weird gnutls error...
Tristanto
@rustyworks
Aug 10 2015 09:59
find me
Tristanto
@rustyworks
Aug 10 2015 10:09
find home
CamperBot
@camperbot
Aug 10 2015 10:09

find home

[0] home

Tristanto
@rustyworks
Aug 10 2015 10:09
Ah, finally I can go home
Aniruddh Agarwal
@anrddh
Aug 10 2015 10:37
Guys
If I am routing with Angular, then how will authentication with Passport work?
Justin Scoggin
@jscogg
Aug 10 2015 11:03

Working on the "Pig Latin" bonfire... here's what I've got so far:

function translate (str) {
  var arr = str.split('');
  var consonantStart;
  while (arr.indexOf("a" || "e" || "i" || "o" || "u") !== 0) {
    var moveLetter = arr.splice(0, 1);
    arr.push(moveLetter);
    consonantStart = true;
  }
  if (consonantStart === true) {
    arr.push("ay");
  } else {
    arr.push("way");
  }
  str = arr.join('');
  return str;
}

Am I close?

DTing
@dting
Aug 10 2015 11:11
bf pig latin
CamperBot
@camperbot
Aug 10 2015 11:11

:fire:Bonfire: Pig Latin :link:

function translate(str) {
 return str;
}

translate("consonant");

Translate the provided string to pig latin.
<a href="http://en.wikipedia.org/wiki/Pig_Latin">Pig Latin</a> takes the first consonant (or consonant cluster) of an English word, moves it to the end of the word and suffixes an "ay".
If a word begins with a vowel you just add "way" to the end.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

type: bf details bf links bf spoiler

DTing
@dting
Aug 10 2015 11:13
@jscogg i don't believe this works the way you think it does arr.indexOf("a" || "e" || "i" || "o" || "u")
that will always check check for indexOf "a" because "a" will evaluate to truthy so the || will never do anything.
Justin Scoggin
@jscogg
Aug 10 2015 11:15
@dting could I do something like arr.indexOf(/^[aeiou]/i) instead, or does that do the same thing?
DTing
@dting
Aug 10 2015 11:17
@jscogg I don't think indexOf takes regex.
you could just use regex.
or actually, sorry, you split the string. You can use a hash and checks in?
Justin Scoggin
@jscogg
Aug 10 2015 11:19
you lost me :confused:
DTing
@dting
Aug 10 2015 11:20
var vowels = {a:true,  e:true, i:true, o:true, u:true};
...

while(!(arr[0] in vowels)) {
...
or i guess !(arr[0] in vowels)
Sean Campbell
@natac13
Aug 10 2015 11:24
@jscogg I think this might help.... I have not fully tested but....
function translate (str) {
  var arr = str.split('');
  var consonantStart;
  while (arr.indexOf("a") !== 0 && arr.indexOf("e") !== 0 && arr.indexOf("i") !== 0 && arr.indexOf("o") !== 0 && arr.indexOf("u") !== 0) {
    var moveLetter = arr.splice(0, 1);
    arr.push(moveLetter);
    consonantStart = true;
  }
  if (consonantStart === true) {
    arr.push("ay");
  } else {
    arr.push("way");
  }
  str = arr.join('');
  return str;
}

translate("globe");
@jscogg Yep so you were very close then!!
Just had to change to ors to ands! Good job man
@jscogg It passes the tests lol
Justin Scoggin
@jscogg
Aug 10 2015 11:28
@natac13 I knew I was almost there! Thanks. :smile:
@dting could you link me the MDN docs on what you're doing with the vowels variable there?
Justin Scoggin
@jscogg
Aug 10 2015 11:36
Thanks! I get what you did now.
Raincode
@Raincode
Aug 10 2015 11:59
Hi, could someone explain this code to me, I have trouble understanding what exactly this apply thing does (even after reading MDN):
Array.prototype.concatAll = function() {
    var results = [];
    this.forEach(function(subArray) {
        results.push.apply(results, subArray);
    });

    return results;
};
I mean push is a function how can I use the . on it?
It should take arguments in ()
Ammar Ali Shah
@AmmarAliShah
Aug 10 2015 12:37
Why won't this work?
var x = 1;
function factorialize(num) {
  for(i = 1; i <= num; i++){
    x *= i;
  }
  num = x;
  return num;
}

factorialize(20);
Mistereo
@Mistereo
Aug 10 2015 12:41
@AmmarAliShah try to call your function two times in a row at browser console.
Reggie
@Reggie01
Aug 10 2015 12:42
@Raincode try reading https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function read the definition section and Properties and Methods of Function section or tldr all functions inherit methods through the prototype chain from function prototype. So Function.prototype.apply method is inherited which allows you to call it on the Array.prototype.push function. If you have Chrome brower try typing in blue = function() {}; into the console. Hit enter. Then type blue and period. All the inherited methods from Object and Function should show up. Also, look at the left sidebar https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array look towards the bottom of the sidebar and you will see Array inherits from Object and Function.
ignatius willie
@obongowo
Aug 10 2015 13:05
hello world
CamperBot
@camperbot
Aug 10 2015 13:05

welcome to FreeCodeCamp @obongowo!

ignatius willie
@obongowo
Aug 10 2015 13:05
pls am stuck
need help
Harvey
@harvey56
Aug 10 2015 13:06
I got a question on bonfire 23 :
the test shows that glove is supposed to become oveglay
but that means you send the first 2 consonants to the end, and not just the first one
did you make it a particular rule just for this word ?
Chanan van Schaick
@ChananNL
Aug 10 2015 13:08
@obongowo "You can start a comment with <!-- and end a comment with --> " it is explanied in the text itself, so if you remove the <!-- and --> you have solved the problem
Mistereo
@Mistereo
Aug 10 2015 13:08
@obongowo everything between <!-- and --> is a comments in HTML.
@harvey56 "Pig Latin takes the first consonant (or consonant cluster)"
@harvey56 if your word starts with 2/3/n consonants they all should be moved to the end.
Harvey
@harvey56
Aug 10 2015 13:11
@Mistereo got it, thanks :)
ignatius willie
@obongowo
Aug 10 2015 13:11
got it thanks!!!!!
@Mistereo and @ChananNL thanks guys
Chanan van Schaick
@ChananNL
Aug 10 2015 13:13
@obongowo you are welcome
Matthew Barber
@Honno
Aug 10 2015 13:20

Hey guys, need some help

var objArray = [{
  prop1: "hi",
  prop2: "bye"
}];
console.log(objArray) // prints [[object Object] {prop1: "hi", prop2: "bye"}]

objIndex = objArray[0];
console.log(objIndex); // prints [object Object] {prop1: "hi", prop2: "bye"}

objJoin = objArray.join("");
console.log(objJoin); // prints "[object Object]"

How do I extra the obj inside the array without using indexes?

Ozy Design & Software
@OzySky
Aug 10 2015 13:30
@Honno what do you mean by 'extra'?
Matthew Barber
@Honno
Aug 10 2015 13:31
@ozydesign Ok so in the end I used
wantedString = objArray.map(function(value) {
  return value.prop1;
})'
I wanted to get the value prop1
which was in a string
without doing something like objArray[0].prop1
Ozy Design & Software
@OzySky
Aug 10 2015 13:31
ok
Matthew Barber
@Honno
Aug 10 2015 13:32
part of the functional programming bit in FCC
Ozy Design & Software
@OzySky
Aug 10 2015 13:33
@Honno a pain, right?
lol
Matthew Barber
@Honno
Aug 10 2015 13:33
@ozydesign you know it :(
but interesting
Ozy Design & Software
@OzySky
Aug 10 2015 13:33
@Honno I'm also doing it now
Matthew Barber
@Honno
Aug 10 2015 13:34
just kind of labourious when you're used to complete a bonfire in 20mins-1hour time, not just focus on one thing FCC links heh
ah cool, I'll uh, race ya
JMitnik
@JMitnik
Aug 10 2015 13:35
Quick question: how you add an image with jQuery, if the image's source is stored inside a variable?
I have trouble getting the src to work with variable imageUrl
Ozy Design & Software
@OzySky
Aug 10 2015 13:36
@Honno you're on mate
Matthew Barber
@Honno
Aug 10 2015 13:36
@ozydesign no cheating ;)
Paul
@pauliwoggius
Aug 10 2015 13:40
@JMitnik you can use the attr method from jQuery to change the src
JMitnik
@JMitnik
Aug 10 2015 13:41
@pauliwoggius well, what I meant was, if I want to append an image tag, how does the src part with the url work, if the url is in a variable
    $('#temp').append('<img src="' + imageUrl + '">')
This is what I am trying to do, but it is not really working
Paul
@pauliwoggius
Aug 10 2015 13:43
you might have to escape the "s
$('#temp').append('<img src=\"' + imageUrl + '\">')
JMitnik
@JMitnik
Aug 10 2015 13:44
Nvm, I got it(forgot to put the .png in the imageUrl), thanks anyways :)
Robert Richey
@0x0936
Aug 10 2015 13:45
var $img = $("<img>");
var imageUrl = "cat.jpg";
$img.attr("src", imageUrl);
$("#temp").append($img);
Ozy Design & Software
@OzySky
Aug 10 2015 13:50
@Honno what exercise are you on?
Matthew Barber
@Honno
Aug 10 2015 13:50
@ozydesign 15, you?
Ozy Design & Software
@OzySky
Aug 10 2015 13:51
11 doesn't want to accept my answer :pensive:
Matthew Barber
@Honno
Aug 10 2015 13:52
@ozydesign lets see the code :)
just the return bit ofc haha
Ozy Design & Software
@OzySky
Aug 10 2015 13:53
@Honno lol, obviously
Paul
@pauliwoggius
Aug 10 2015 13:53
hmm.. how come line 28 in my pen doesn't seem to be working? the console shows empty array
http://codepen.io/pauliwoggius/pen/pJYwEe?editors=001
JMitnik
@JMitnik
Aug 10 2015 13:54
Anyone in here who can quickly check if my pen is working for them?
(unembeded)
Matthew Barber
@Honno
Aug 10 2015 13:55
@JMitnik It works! And I'm on a beach!
JMitnik
@JMitnik
Aug 10 2015 13:55
@Honno Awesome :D hahahah
Paul
@pauliwoggius
Aug 10 2015 13:56
where is my margarita? :(
tinako97
@tinako97
Aug 10 2015 13:57

This is probably really stupid, but why can't I adjust the padding in my html? Everything is jammed together vertically:

<link rel='stylesheet' href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css' />

<body>
  <div class="container-fluid">
    <button id="get-another-quote-button" class='btn btn-primary btn-block'>Click to get a quote...</button>

    <div id='quote-holder' class='text-center'></div>
  </div>
</body>

Tried both of the following:

div {padding: 50;}
.button{padding:50;}
Paul
@pauliwoggius
Aug 10 2015 13:58
Ctrl + Shift + I and use the element inspector to find out whats what
Matthew Barber
@Honno
Aug 10 2015 13:59
@tinako97 you're not using .button?
oh wait I'm stupid dont mind me
I need to sleep, been plowing thru code all day
bye cruel world
Paul
@pauliwoggius
Aug 10 2015 14:00
lol
tinako97
@tinako97
Aug 10 2015 14:08
It doesn't even work when I remove the bootstrap reference (I don't see it loaded under codepen settings, either). Is my syntax right?
@pauliwoggius I find it difficult to tell what's going on with all the codepen stuff in there.
Paul
@pauliwoggius
Aug 10 2015 14:11
@tinako97 can you link to the codepen?
tinako97
@tinako97
Aug 10 2015 14:11
Paul
@pauliwoggius
Aug 10 2015 14:12
@tinako97 are you using chrome or firefox?
tinako97
@tinako97
Aug 10 2015 14:12
Chrome. @pauliwoggius
Paul
@pauliwoggius
Aug 10 2015 14:15
@tinako97 what is it you are trying to move where?
tinako97
@tinako97
Aug 10 2015 14:17
I want some vertical spacing between the button, the edge of the screen, and the quote. It doesn't look so horrible now, but when I turn on bootstrap, the button loses ALL padding and is jammed against the side. @pauliwoggius
I put bootstrap back on.
@pauliwoggius With btn-block it doesn't look so bad, but I'd like to be able to change it.
Paul
@pauliwoggius
Aug 10 2015 14:18
@tinako97 when you hit Ctrl+Shift+I, click on the little magnifying glass and hover around http://i.imgur.com/bkKM4TP.png
you'll be able to see the classes applied and from what it sounds like, margin might be a more appropriate property to adjust?
tinako97
@tinako97
Aug 10 2015 14:20
@pauliwoggius I had tried margin. I will try again.
Paul
@pauliwoggius
Aug 10 2015 14:21
@tinako97 I'm not a CSS expert and still learning myself, but that's how I would approach it. Just need to make sure that the right property is applied to the right class/element/id.
Ozy Design & Software
@OzySky
Aug 10 2015 14:21
@tinako97 your using bootstrap, right?
tinako97
@tinako97
Aug 10 2015 14:21
@pauliwoggius nothing. Shouldn't either div or .button apply? Yes, bootstrap. But it also fails without bootstrap.
@pauliwoggius by nothing I mean margin didn't work.
Ozy Design & Software
@OzySky
Aug 10 2015 14:22
if so you need to encapsulate your content (i.e button) with a <div class="row"
tinako97
@tinako97
Aug 10 2015 14:22
@ozydesign and then apply formatting to that row?
Ozy Design & Software
@OzySky
Aug 10 2015 14:24
no then make another div with class col and the size of column you want (for e.g col-md-6 for half screen column). Check bootstrap docs for more info.
and inside your content
tinako97
@tinako97
Aug 10 2015 14:25
@ozydesign why would it also fail without bootstrap loaded?
Alejandro Tejada
@wannabecoding
Aug 10 2015 14:25
Hi everyone.
Giorgio Giuliani
@gigiuliani
Aug 10 2015 14:27
BF SPOILER
CamperBot
@camperbot
Aug 10 2015 14:27
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Alejandro Tejada
@wannabecoding
Aug 10 2015 14:28
I'm having trouble understanding a recursive function. Was hoping someone can help me understand this?
This is from bonfire 2 - factorialize a number
tinako97
@tinako97
Aug 10 2015 14:29
@ozydesign my code works in jsbin. It is something in codepen.
Paul
@pauliwoggius
Aug 10 2015 14:30
@tinako97 is the code exactly the same and do both have bootstrap on/off?
Ozy Design & Software
@OzySky
Aug 10 2015 14:30
@tinako97 ok, good to know then
Paul
@pauliwoggius
Aug 10 2015 14:31
also, wrapping the button element in a div, then applying margin works pretty well
tinako97
@tinako97
Aug 10 2015 14:32
Here is the new pen in codepen: http://codepen.io/tinako97/pen/eNXVxg
And here is the new bin in jsbin: oops: http://jsbin.com/sahigo/edit?html,css,output
Moisés Man
@moigithub
Aug 10 2015 14:32
@tinako97 u adding 50 what?? pixels em % ??
u need to specify what unit u using
50px;
50em;
50%;
tinako97
@tinako97
Aug 10 2015 14:33
@moigithub I tried that too.
@moigithub Oh, now that is working.
Moisés Man
@moigithub
Aug 10 2015 14:34
:)
Paul
@pauliwoggius
Aug 10 2015 14:34
lol
tinako97
@tinako97
Aug 10 2015 14:35
@moigithub @pauliwoggius @ozydesign I had put a space between the number and px (eg 500 px) and that doesn't work in codepen. Though you don't need anything at all in jabin, apparently.
I knew it was something stupid. thanks @moigithub thanks @pauliwoggius thanks @ozydesign
Paul
@pauliwoggius
Aug 10 2015 14:37
@tinako97 yep
Dayne Wright
@daynewright
Aug 10 2015 14:56
Need a little help on bofire Make a Person.
I am confused by the get and set it wants on each part of the name. Has anyone completed this?
Paul
@pauliwoggius
Aug 10 2015 14:58
@Daynewr yep.. the methods are kinda self-explanatory on what they want you to return
Dayne Wright
@daynewright
Aug 10 2015 15:00
@pauliwoggius Well…am I on the right track?
var Person = function(firstAndLast) {

    var splitName = firstAndLast.split(' ');

        this.setFirstName = function() {
            return splitName[0];
        };
        this.setLastName = function() {
            return splitName[1];
        };
        this.setFullName = function() {
            return firstAndLast;
        };

};


var bob = new Person('Bob Ross’);
Paul
@pauliwoggius
Aug 10 2015 15:03
@Daynewr kind of. The setFirstName method should replace the first name of the person with a new one.
Dayne Wright
@daynewright
Aug 10 2015 15:04
I guess I am lost on what exactly the bonfire is asking me to do.
CamperBot
@camperbot
Aug 10 2015 15:04
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Roy
@CruelCoin
Aug 10 2015 15:05
bonfire make a person
CamperBot
@camperbot
Aug 10 2015 15:05
Sorry, can't find a bonfire called make a person. [ Check the map? ]
Paul
@pauliwoggius
Aug 10 2015 15:05
lol
Roy
@CruelCoin
Aug 10 2015 15:06
What is the name of the bonfire?
CamperBot
@camperbot
Aug 10 2015 15:06
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Paul
@pauliwoggius
Aug 10 2015 15:07
that is the name of the bonfire, not sure why it didn't take it
Alejandro Tejada
@wannabecoding
Aug 10 2015 15:07
bonfire factorialize a number
CamperBot
@camperbot
Aug 10 2015 15:07

:fire:Bonfire: Factorialize a Number :link:

function factorialize(num) {
  return num;
}

factorialize(5);

Return the factorial of the provided integer.
If the integer is represented with the letter n, a factorial is the product of all positive integers less than or equal to n.
Factorials are often represented with the shorthand notation n!
For example: 5! = 1 2 3 4 5 = 120f
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.

type: bf details bf links bf spoiler

Alejandro Tejada
@wannabecoding
Aug 10 2015 15:08
bf spoiler
CamperBot
@camperbot
Aug 10 2015 15:08
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Paul
@pauliwoggius
Aug 10 2015 15:08
maybe because it is in 'Intermediate Algorithm Scripting'?
Roy
@CruelCoin
Aug 10 2015 15:08
@Daynewr You need to read the instructions more carefully
@Daynewr It is asking you for 6 methods, and you are only giving it 3
@Daynewr Each setter should set (change) the exisiting data according to whats coming in, and the get(retrieval should return the data.
Setters should change, getters should return
Alejandro Tejada
@wannabecoding
Aug 10 2015 15:10
I got the answer on the factorialize bonfire but I don't quite understand recursive functions. Can someone help me understand them? I can post my code if required
Daniel Neumann
@NeuwDk
Aug 10 2015 15:11
@wannabecoding the rule to factorialize is to remember, that when you say 3! it's equal to 321 , so 3(3-1)((3-1)-1) if that makes sense
Alejandro Tejada
@wannabecoding
Aug 10 2015 15:11
Yes, that I've got under wraps :)
It's just recursive functions, sounds like a loop to me, but I don't know how it decides when to stop
here's my code
function factorialize(num) {
  if (num === 0)
      { return 1; }
    else
      { return num * factorialize( num - 1 ); }
}

factorialize(5);
Paul
@pauliwoggius
Aug 10 2015 15:12
it stops if the specified conditions are met
Nic Galluzzo
@ngalluzzo
Aug 10 2015 15:12
@wannabecoding how about starting at the highest number all the way down to the lowest?
Alejandro Tejada
@wannabecoding
Aug 10 2015 15:13
I didn't even know I had entered a recursive function until someone cleared that up for me yesterday on here
Daniel Neumann
@NeuwDk
Aug 10 2015 15:13
@wannabecoding You have to tell it when to stop, and that you do, at your if statement. Because, you don't call the function in your return anymore. So from there it return 1, and then the call above it in the stack has it's info to return and so on
Alejandro Tejada
@wannabecoding
Aug 10 2015 15:14
@NeuwDk okay, I had imagined that but I wasn't sure of it. So when we pass 5 in factorialize, it takes the num (5) and multiplies it times num - 1 (5-1), until it reaches 1, which is the if statement?
So the if statement stops the recursive function?
Paul
@pauliwoggius
Aug 10 2015 15:15
@wannabecoding yes, it won't invoke the function if num === 0
Alejandro Tejada
@wannabecoding
Aug 10 2015 15:16
Thanks, guys.
I see the cycle now
Daniel Neumann
@NeuwDk
Aug 10 2015 15:17
@wannabecoding yes, you have to remember that you call the function everytime num is not equal to 0. And when it hits 0 it just returns 1.
Michael Perkhofer
@mperkh
Aug 10 2015 15:17
Hi. Doing the 'pairwise' bonfire, and become braindead.. :/ Perhaps anyone can see, why this function returns 7 instead of 11. I also guess my solution does only work with [1,4,2,3,0,5]but not with [0, 0, 0, 0, 1, 1].
function pairwise(arr, arg) {
  return arr.reduce(function(prev, elem, idx){
    return prev + arr.slice(idx).reduce(function(prev, curr){
        if (elem + curr === arg) return idx + arr.indexOf(curr);
        return 0;
      }, 0);
  }, 0);
}

console.log(pairwise([1,4,2,3,0,5], 7));
//console.log(pairwise([0, 0, 0, 0, 1, 1], 1));
Giorgio Giuliani
@gigiuliani
Aug 10 2015 15:18
@wannabecoding you can use a WHILE statement
while n>1 you keep on decreasing it by 1 and multiplying it to the total
vbobjee
@vbobjee
Aug 10 2015 15:19
Can somebody explain the Bonfire: Arguments Optional? I dont understand the explanation given for 'when only one argument is present'.
I can use prompt to get a user input, but how can I return a function that is waiting for one more argument?
Michael Perkhofer
@mperkh
Aug 10 2015 15:21
@vbobjee look at the tests. there you will see, they make the call add(2)(3).
Chocobowings
@chocobowings
Aug 10 2015 15:21
@vbobjee You need to return a function that takes an argument. It is called closures
Michael Perkhofer
@mperkh
Aug 10 2015 15:22
@vbobjee in the case of only one given argument, as in add(2), it has to return a function that gets then invoked with (3).
Alejandro Tejada
@wannabecoding
Aug 10 2015 15:22
@gigiuliani That's a great idea! Let me solve it with a while loop
as well
Chocobowings
@chocobowings
Aug 10 2015 15:22
@vbobjee
 return function sample(x)
        {
         "Do something with x here "
          }
Daniel Neumann
@NeuwDk
Aug 10 2015 15:23
@wannabecoding if you want to use a loop, why not use a for loop? You already have the numbers about when to stop, and you're given when to start.
Chocobowings
@chocobowings
Aug 10 2015 15:25
@mperkh Do you still need help with pairwise?
Michael Perkhofer
@mperkh
Aug 10 2015 15:25
yes.. :|
Chocobowings
@chocobowings
Aug 10 2015 15:26
@mperkh What do you need help with ?
Michael Perkhofer
@mperkh
Aug 10 2015 15:26
dont know why the outer reduce returns '7', instead of '11'.
Chocobowings
@chocobowings
Aug 10 2015 15:27
@mperkh ok give me a min i will check :)
Michael Perkhofer
@mperkh
Aug 10 2015 15:27
the inner reduce should produce '4' and '7', which the outer reduce should sum up to '11'.
doing console lookups in the inner reduce, it seems, 4 and 7 is produces. But the outer reduce does nit get these values correctly.
Alejandro Tejada
@wannabecoding
Aug 10 2015 15:29
Let me try it with a for loop as well. Will report back in a bit
Stuck in the office
Moisés Man
@moigithub
Aug 10 2015 15:33
This message was deleted
reismichel
@reismichel
Aug 10 2015 15:33
does anyone can help me with the "reverse a string" challenge?
Michael Perkhofer
@mperkh
Aug 10 2015 15:35
@moigithub no, prev on the outer, is the previous result of the previous reduce() return. See 2nd table at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce#Description
Alexa Rae Schreffler
@alexaraes
Aug 10 2015 15:36
@reismichel maybe do a for loop and then use unshift?
Moisés Man
@moigithub
Aug 10 2015 15:41
@mperkh ok
how u check if u already used the num ? for 2nums wich sum = x
u cant reuse those 2nums again
Leandro Santos
@leaudro
Aug 10 2015 15:41
@reismichel you can turn the string into an array, use Array.reverse() and them turn it into an string again
vbobjee
@vbobjee
Aug 10 2015 15:41
@chocobowings @mperkh Thanks! I will look into it.
Aliza
@alizagoldberg
Aug 10 2015 15:42

I have a quick question about the last part of the Codecademy jQuery lessons. My code is:
$(document).ready(function(){
$("#one").after("Will this work?")
$par=$("p")
$("#two").after($par);
;});

and my error message says "Oops, try again. It looks like your <p> is still after the <div> with ID #one."
Does anyone know what I may be doing wrong?

Moisés Man
@moigithub
Aug 10 2015 15:42
bf pairwise
CamperBot
@camperbot
Aug 10 2015 15:42

:fire:Waypoint: Pair Program on Bonfires :link:

119657641

Please note that the video for this challenge is a little outdated, and doesn't perfectly match these steps. We plan to record a new video soon.
OK, we're finally ready to start pair programming!
Pair Programming is where two people code together on the same computer. It is an efficient way to collaborate, and widely practiced at software companies. Pair Programming is one of the core concepts of "Agile" Software Development, which you will hear more about later.
Many people use Skype or Google Hangouts to pair program, but if you talk with professional software engineers, they will tell you that it's not really pair programming unless both people have the ability to use the keyboard and mouse.
The most popular tool for pair programming is Screenhero. You can download Screenhero for <a href='http://links.screenhero.com/e/c/eyJlbWFpbF9pZCI6Ik1qQTNNem9XQkNJQ1pBQUNjd0FYQVZrVEdnRkxNamtfX0JWZEdGVEpSZkVCWlRwbFpXRTBNamM0WVMxaE56SmlMVEV4WlRRdE9HUXpZUzFpWXpVNE1HRTJNalkxTldNNk1UUTJNVEEyQUE9PSIsInBvc2l0aW9uIjowLCJocmVmIjoiaHR0cDovL2RsLnNjcmVlbmhlcm8uY29tL3NtYXJ0ZG93bmxvYWQvZklYQU1UUUJBTEtQQkhQTC9TY3JlZW5oZXJvLnppcD9zb3VyY2U9d2ViIn0=' target='_blank'>Mac</a> or <a href='http://links.screenhero.com/e/c/eyJlbWFpbF9pZCI6Ik1qQTNNem9XQkNJQ1pBQUNjd0FYQVZrVEdnRkxNamtfX0JWZEdGVEpSZkVCWlRwbFpXRTBNamM0WVMxaE56SmlMVEV4WlRRdE9HUXpZUzFpWXpVNE1HRTJNalkxTldNNk1UUTJNVEEyQUE9PSIsInBvc2l0aW9uIjoxLCJocmVmIjoiaHR0cDovL2RsLnNjcmVlbmhlcm8uY29tL3NtYXJ0ZG93bmxvYWQvZklYQU1UUUJBTEtQQkhQTC9TY3JlZW5oZXJvLXNldHVwLmV4ZSJ9' target='_blank'>Windows</a>. Create your new user account from within the app.
We have a special chat room for people ready to pair program. Go to our <a href='//gitter.im/FreeCodeCamp/LetsPair' target='_blank'>LetsPair chatroom on Gitter</a> and type "Hello Pair Programmers!"
If someone is available, they will be your "pair" - the person you pair programming with.
If no one gets back to you in the first few minutes, don't worry. There will be lots of opportunities to pair program in the future.
If someone does get back to you, private message them and ask for the email address they used to register Screenhero.
Add them as a new contact in Screenhero, then click the monitor-looking button to attempt to share your screen with them.
Once the Screenhero session starts, your screen's margins will glow orange. You are now sharing your screen.
Your pair will have their own cursor, and will be able to type text on his or her keyboard.
Now it's time to tackle our Bonfires. You can begin them by advancing to the next challenge.
Once you you finish pair programming, end the session in Screenhero session.
Congratulations! You have completed your first pair programming session.
Pair program as much as possible with different campers until you've completed all the Bonfire challenges. This is a big time investment, but the JavaScript practice you get will be well worth it!
Mark this Waypoint complete and move on.

type: bf details bf links bf spoiler

Moisés Man
@moigithub
Aug 10 2015 15:43
bf pairwise
CamperBot
@camperbot
Aug 10 2015 15:43
Sorry, can't find a bonfire called pairwise. [ Check the map? ]
Moisés Man
@moigithub
Aug 10 2015 15:45
@mperkh "Return the sum of all indices of elements of 'arr' that can be paired with one other element to form a sum that equals the value in the second argument 'arg'. If multiple sums are possible, return the smallest sum. Once an element has been used, it cannot be reused to pair with another."
Dayne Wright
@daynewright
Aug 10 2015 15:46
Ok..Bonfire Make a Person is just not clicking with me. Here is what I have so far:
var Person = function(firstAndLast) {

    var splitName = firstAndLast.split(' ');

        this.getFirstName = function() {
            return splitName[0];
        };
        this.getLastName = function() {
            return splitName[1];
        };
        this.getFullName = function() {
            return firstAndLast;
        };

        this.setFullName = function (full) {
            full = firstAndLast;
        };

        this.setFirstName = function (first) {
            first = splitName[0];
        };

        this.setLastName = function (last) {
            last = splitName[1];
        };

};

var bob = new Person('Bob Ross’);
Michael Perkhofer
@mperkh
Aug 10 2015 15:46
@moigithub thats true. I know that. But will implement that later.
Moisés Man
@moigithub
Aug 10 2015 15:46
@alizagoldberg
"Will this work?" <-- should be a paragraph
so...
"<p>Will this work?</p>"
Aliza
@alizagoldberg
Aug 10 2015 15:47
@moigithub : Good catch! Thanks so much. I made the change, but I still get the same error message
Moisés Man
@moigithub
Aug 10 2015 15:47
@mperkh then u wil NOT have correct results...
Michael Perkhofer
@mperkh
Aug 10 2015 15:47
@moigithub But maybe, that will never work with the 2 reduces()'s.
@moigithub with [1,4,2,3,0,5] it should work.
Aliza
@alizagoldberg
Aug 10 2015 15:48

I got it!
$(document).ready(function(){
$('#one').after("Will this work?");

var $paragraph = $('p');

$('#two').after($paragraph);

})

Moisés Man
@moigithub
Aug 10 2015 15:49
@mperkh i think i did with 1 reduce + 1for didnt tryed another way after got it working (im lazy :) )
Michael Perkhofer
@mperkh
Aug 10 2015 15:49
ok, thx.
JMitnik
@JMitnik
Aug 10 2015 15:49
Am I missing something with the twitch API call?
    $.getJSON("https://api.twitch.tv/kraken/streams/freecodecamp",function(json){
      console.log(json);
    })
I get the following message in my console
Origin http://s.codepen.io not found in Access-Control-Allow-Origin header.
XMLHttpRequest: Network Error 0x80700013, Could not complete the operation due to error 80700013.
Juan Martínez
@jbmartinez
Aug 10 2015 15:51
@JMitnik you cannot access encrypted resources (https) from unencrypted sites (http). Try using jsonp instead of json
Dayne Wright
@daynewright
Aug 10 2015 15:51
Anyone able to look over my Make a Person above and give any direction?
JMitnik
@JMitnik
Aug 10 2015 15:53
@jbmartinez gotcha, thanks!
Juan Martínez
@jbmartinez
Aug 10 2015 15:54
@JMitnik no problem
Moisés Man
@moigithub
Aug 10 2015 15:55

@Daynewr

this.setFirstName = function (first) {
            first = splitName[0];
        };

        this.setLastName = function (last) {

when u using those methods.. where u have the "new" data ??
on first/last or on splitName[] ??

@Daynewr those methods used to change the old data...
Paul
@pauliwoggius
Aug 10 2015 15:56
how come my colFill array isn't getting filled?
http://codepen.io/pauliwoggius/pen/LVadxg?editors=101
Dayne Wright
@daynewright
Aug 10 2015 15:57
@moigithub I thought it was just changed by bob.setFirstName(‘Jim’);.
obviously not correct
Moisés Man
@moigithub
Aug 10 2015 15:59
@Daynewr
var bob = new Person('Bob Ross’);
bob.setFirstName("Jim"); // change name
console.log( bob.getFullName() ) ; // <--- should return Jim Ross
Ezekiel dela Peña
@ezekielvdp
Aug 10 2015 16:00
Hi guys, I need help with BonFire#15 can I have some tips or helpful references on how can I solve the challenge? I don't want to be spoonfed so hopefully no codes that is finished. Thanks in advance!
Dayne Wright
@daynewright
Aug 10 2015 16:01
@moigithub Yes. That is what I thought, but it isn’t working that way
Moisés Man
@moigithub
Aug 10 2015 16:02
@Daynewr
first = splitName[0]; <-- incorrect
splitName[0] = first; <-- should be
Dayne Wright
@daynewright
Aug 10 2015 16:03
ah
Moisés Man
@moigithub
Aug 10 2015 16:03

@Daynewr also this is wrong...

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

        this.setFullName = function (full) {
            full = firstAndLast;
        };

u need to work with the "internal" variable splitName
not the argument/parameter firstAndLast

Dayne Wright
@daynewright
Aug 10 2015 16:04
@moigithub looks like I have all kinds of issues :)
Moisés Man
@moigithub
Aug 10 2015 16:05
@Daynewr its part of the learning process ;)
Dayne Wright
@daynewright
Aug 10 2015 16:05
I see..so I was just returning what was passed in?
Dayne Wright
@daynewright
Aug 10 2015 16:12
ok..got it to work :)
var Person = function(firstAndLast) {

    var splitName = firstAndLast.split(' ');

        this.setFullName = function (full) {
             splitName = full;
        };

        this.setFirstName = function (first) {
            splitName[0] = first;
        };

        this.setLastName = function (last) {
            splitName[1] = last;
        };


        this.getFirstName = function() {
            return splitName[0];
        };
        this.getLastName = function() {
            return splitName[1];
        };
        this.getFullName = function() {
            if(Array.isArray(splitName)) {
              return splitName.join(' ');
            }
          return splitName;
        };

};
Moisés Man
@moigithub
Aug 10 2015 16:17
@Daynewr yes but.. hmm
when u create a new person... var bob = new Person('Bob Ross’); var splitName = firstAndLast.split(' '); splitName will be an array ['Bob','Ross']
then if u change fullname bob.setFullName("Jim Carter"); u doin this splitName = full; so splitName will be a String "Jim Carter"
so IF u do bob.getFirstName(); it will return splitName[0]; so... "Jim Carter"[0] <--- will return ????
Brett Guillory
@kurzninja
Aug 10 2015 16:21
Anyone doing the Random Quote zipline have problems with Access-Control-Allow-Origin errors trying to access an API from Codepen?
M Used
@mildused
Aug 10 2015 16:22
@kurzninja Share please
Brett Guillory
@kurzninja
Aug 10 2015 16:22
Share what?
Moisés Man
@moigithub
Aug 10 2015 16:22
@Daynewr
var bob = new Person('Bob Ross’);
bob.setFullName("Jim Carter"); //<-- change name
console.log(bob.getFirstName()); //<-- should return "Jim"
Brett Guillory
@kurzninja
Aug 10 2015 16:22
XMLHttpRequest cannot load http://quotes.stormconsultancy.co.uk/quotes.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access. The response had HTTP status code 500.
Moisés Man
@moigithub
Aug 10 2015 16:22
@kurzninja do jsonP requests
Brett Guillory
@kurzninja
Aug 10 2015 16:25
I don't know what you mean by that
Moisés Man
@moigithub
Aug 10 2015 16:25
google ??
Brett Guillory
@kurzninja
Aug 10 2015 16:25
I am
It's a shame that's not part of the Codepen Ajax instructions
Moisés Man
@moigithub
Aug 10 2015 16:28
if u using jquery.. getJSON u need to add "?callback=?" to ur URL http://api.jquery.com/jquery.getjson/
Bill
@kirah1314
Aug 10 2015 16:29
'''
Paul
@pauliwoggius
Aug 10 2015 16:32
@moigithub have you seen the pen I linked earlier?
Moisés Man
@moigithub
Aug 10 2015 16:33
nope
im also checking mongodb mooc :) https://university.mongodb.com/courses/M101JS/about
@pauliwoggius if u open devtools / console.. u will see this error
"Uncaught TypeError: Cannot read property 'headline' of undefined"
@pauliwoggius u doin ...
$.get(api, function(data) { ... });
and then trying to access collFill data
$('body').append('<h3>' + colFill[0][0].headline + '<\/h3>');
@pauliwoggius BUT
since its a ASYNC request.. data its not ready yet, so when u trying to body.append it return undefined
Paul
@pauliwoggius
Aug 10 2015 16:38
I knew it was something to do with async, but a little foggy on how to work around this
Bill
@kirah1314
Aug 10 2015 16:39
'''
CamperBot
@camperbot
Aug 10 2015 16:39
:bulb: to format code use backticks! ``` more info
Moisés Man
@moigithub
Aug 10 2015 16:39
move all ur code inside the callback..
John Chau
@ydjjabt
Aug 10 2015 16:39
@Daynewr hey, where the answer to Robot
William Wagner
@wcwagner
Aug 10 2015 16:47
For example, 'aab' should return 2 because it has 6 total permutations, but only 2 of them don't have the same letter (in this case 'a') repeating.
Can anyone explain this
Paul
@pauliwoggius
Aug 10 2015 16:47
@moigithub moving the code into the callback doesn't seem to produce results
Moisés Man
@moigithub
Aug 10 2015 16:49
@pauliwoggius post link
Moisés Man
@moigithub
Aug 10 2015 16:50
add..
console.log(collFill)
Paul
@pauliwoggius
Aug 10 2015 16:51
right, it's empty.. how come line 7 doesn't seem to be firing off?
Moisés Man
@moigithub
Aug 10 2015 16:52
console.log all ur variables :P
ok
colCount = 8 (after calc )
for (var x = 0; x > colCount; x++) {
for (var x = 0; x > 8; x++) { //<--- 0>8 =false.. so that for will NOT execute
Paul
@pauliwoggius
Aug 10 2015 16:55
it's always something stupid.. haha
@moigithub thanks
Moisés Man
@moigithub
Aug 10 2015 16:55
but that nested for
its making a huge array
Paul
@pauliwoggius
Aug 10 2015 16:57
I am noticing this, and am rethinking how to populate propagate the information without it
Bill
@kirah1314
Aug 10 2015 16:59
''''
just testing...
my codes here
and here
and here
''''
CamperBot
@camperbot
Aug 10 2015 16:59
:bulb: to format code use backticks! ``` more info
Moisés Man
@moigithub
Aug 10 2015 17:00
not apostrophes.. but backticks ` (alt 96 ) some keyboard have that key above the tab key or near the enter key
Bill
@kirah1314
Aug 10 2015 17:01
@moigithub thanks, I'm testing ''' :)
CamperBot
@camperbot
Aug 10 2015 17:01
:bulb: to format code use backticks! ``` more info
Bill
@kirah1314
Aug 10 2015 17:02
^ I made that, sorta...
Alejandro Tejada
@wannabecoding
Aug 10 2015 17:07
I finally was able to do it with a do, while loop as well :)
function factorialize(num) {
  if (num === 0) {
    return 1;
  } else {
  do {
    return (num * factorialize(num - 1));
  }
  while (num > 1);
}
}

factorialize(5);
Bill
@kirah1314
Aug 10 2015 17:10
@wannabecoding it works without do/while by the way :)
Alejandro Tejada
@wannabecoding
Aug 10 2015 17:10
lol good catch on my redundancies
I didn't really change anything on my original answer then >_<
function factorialize(num) {
  if (num === 0)
      { return 1; }
    else
      { return num * factorialize( num - 1 ); }
}

factorialize(5);
thought i had figured it out
Bill
@kirah1314
Aug 10 2015 17:12
@wannabecoding all good, it's very clean
Sudeepto
@Sudeepto
Aug 10 2015 17:12

Good evening campers. I am doing the reuse-code-with-decorators waypoint.

In that exercise, I am stuck at Adding methods to constructors

I am not understanding how to refactor the carlike function.

Thank You.

Alejandro Tejada
@wannabecoding
Aug 10 2015 17:13
I'm trying to figure out how to do this with while and for loops
Matthew Senko
@mpskierbg
Aug 10 2015 17:13
what is the importance of knowing if a boolean is a primitaive or an object?
Alejandro Tejada
@wannabecoding
Aug 10 2015 17:13
gonna get back to it
Fabio
@FabioSeves
Aug 10 2015 17:13
After Waypoint: Use a CSS Class to Style an Element teh next challenge gives http://beta.freecodecamp.com/challenges/next-challenge
Bill
@kirah1314
Aug 10 2015 17:13
@wannabecoding I did it with for but not while though
Dayne Wright
@daynewright
Aug 10 2015 17:14
@moigithub Sorry…had to do some things for work.
Bill
@kirah1314
Aug 10 2015 17:15
@wannabecoding if you want to take a look, I can post it with for but without while
Dayne Wright
@daynewright
Aug 10 2015 17:15

@Daynewr yes but.. hmm
when u create a new person... var bob = new Person('Bob Ross’); var splitName = firstAndLast.split(' '); splitName will be an array ['Bob','Ross']
then if u change fullname bob.setFullName("Jim Carter"); u doin this splitName = full; so splitName will be a String "Jim Carter"
so IF u do bob.getFirstName(); it will return splitName[0]; so... "Jim Carter"[0] <--- will return ????

@moigithub Will my last If not correct this?

Alejandro Tejada
@wannabecoding
Aug 10 2015 17:16
@kirah1314 I wouldn't mind seeing that
Bill
@kirah1314
Aug 10 2015 17:16
@wannabecoding FYI:
function factorialize(num) {
  var number = 1; 

  for (var n = 1; n <= num; n++)    
    {
      number *= n;
    }  
  return number; 
}

factorialize(10);
Blairlosaria
@Blairlosaria
Aug 10 2015 17:17
Guys i need help
Untitled.png
Ryan Malm
@Rybar
Aug 10 2015 17:18
@Blairlosaria The OL should not be nested inside a UL.
should be ol > 3 items /ol and then ul, 3 MORE items, /ul.
Alejandro Tejada
@wannabecoding
Aug 10 2015 17:19
@kirah1314 Thanks!
I can actually interpret that and see how it works
Bill
@kirah1314
Aug 10 2015 17:20
@wannabecoding welcome :thumbsup:
Blairlosaria
@Blairlosaria
Aug 10 2015 17:21
@Rybar Thank you! but the example given to me was this For example: <ol><li>hydrogen</li><li>helium</li></ol> would create a numbered list of "hydrogen" and "helium".
@Rybar that's why i got confused. Anyway, thanks man!
Ryan Malm
@Rybar
Aug 10 2015 17:24
right, you'll always have li's nested in your ol or ul tags. but never ol inside ul or vice versa, one is for Ordered Lists, the other Unordered Lists.
Feners4
@Feners4
Aug 10 2015 17:25
using scss, how can I display a colored border around boxes with @include?
DTing
@dting
Aug 10 2015 17:33
bf
bf chunky monkey
dc
@dcsan
Aug 10 2015 17:34
bf monkey
willamgriffin
@willamgriffin
Aug 10 2015 17:36
i'm having an issue with bonfire:least common multiple.

``` function smallestCommons(arr) {

a2 = arr[0];
b2 = arr1;

a = arr[0];
b = arr1;

a = Math.abs(a);
b = Math.abs(b);

if (b > a) {
var temp = a;
a = b;
b = temp;
}

while (true) {
a %= b;
if (a === 0) { gcd = b; }
b %= a;
if (b === 0) { gcd = a; }
break;

}

console.log (gcd);
lcm=((a2*b2)/gcd);
return lcm;

}

smallestCommons([12,30]);

sorry

```function smallestCommons(arr) {

a2 = arr[0];
b2 = arr1;

a = arr[0];
b = arr1;

a = Math.abs(a);
b = Math.abs(b);

if (b > a) {
var temp = a;
a = b;
b = temp;
}

while (true) {
a %= b;
if (a === 0) { gcd = b; }
b %= a;
if (b === 0) { gcd = a; }
break;

}

console.log (gcd);
lcm=((a2*b2)/gcd);
return lcm;

}

smallestCommons([12,30]);
```

ugh
Bill
@kirah1314
Aug 10 2015 17:37
@willamgriffin the backticks ``` need their own lines
willamgriffin
@willamgriffin
Aug 10 2015 17:38
yeah sorry i slipped twice
function smallestCommons(arr) {

  a2 = arr[0];
  b2 = arr[1];

  a = arr[0];
  b = arr[1];

  a = Math.abs(a);
  b = Math.abs(b);

  if (b > a) {
    var temp = a;
    a = b;
    b = temp; 
  }

  while (true) {
    a %= b;
    if (a === 0) { gcd = b; }
    b %= a;
    if (b === 0) { gcd = a; }
    break;

}

  console.log (gcd);
  lcm=((a2*b2)/gcd);
  return lcm;

  }




smallestCommons([12,30]);
Bill
@kirah1314
Aug 10 2015 17:38
help monkey
Michelle
@michelleafleck
Aug 10 2015 17:40
I'm having trouble with Bonfire: Return Largest Numbers in Arrays. Can someone just give me a hint as to what direction to start in without, you know, helping me too much?
willamgriffin
@willamgriffin
Aug 10 2015 17:41
the tests say 1, 5 and 5,1 should be 60?
Dayne Wright
@daynewright
Aug 10 2015 17:46
bf map the debris
CamperBot
@camperbot
Aug 10 2015 17:46

:fire:Bonfire: Map the Debris :link:

function orbitalPeriod(arr) {
  var GM = 398600.4418;
  var earthRadius = 6367.4447;
  return arr;
}

orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);

Return a new array that transforms the element's average altitude into their orbital periods.

more info:  bf details | bf links | hint

Alon Robinson
@ahrobinson
Aug 10 2015 17:47
On the Smallest common multiple bonfire..what exactly does it want me to find. Because the smallest common multiple of 1 and 5 is 5, but it is saying that it should equal 60..and for 1 and 13 it says it should equal 360360???
willamgriffin
@willamgriffin
Aug 10 2015 17:49
thats what im stuck on
Bill
@kirah1314
Aug 10 2015 17:49
troll
CamperBot
@camperbot
Aug 10 2015 17:49
:trollface: troll problems? notify admins here
Dayne Wright
@daynewright
Aug 10 2015 17:50
Is this the right formula I should be looking at for Map the Debris?https://en.wikipedia.org/wiki/Orbital_period#Small_body_orbiting_a_central_body
  arr[0].avgAlt = 2*Math.PI*Math.pow((Math.pow(earthRadius,3)/GM),0.5);
bf map the debris
CamperBot
@camperbot
Aug 10 2015 17:50

:fire:Bonfire: Map the Debris :link:

function orbitalPeriod(arr) {
  var GM = 398600.4418;
  var earthRadius = 6367.4447;
  return arr;
}

orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);

Return a new array that transforms the element's average altitude into their orbital periods.

more info:  bf details | bf links | hint

Alon Robinson
@ahrobinson
Aug 10 2015 17:50
@willamgriffin that doesn't make sense..it should have more explanation
Sean
@seanr707
Aug 10 2015 17:52
@ahrobinson @willamgriffin it is asking you to find the smallest number where all numbers between 1 & 5 (1,2,3,4,5) are all evenly divide into said smallest number.
60 is the smallest number that is evenly divisible by 1,2,3,4,and5
Feners4
@Feners4
Aug 10 2015 17:54
how can I use @include to display a colored border around my article boxes when not in hover... http://codepen.io/Feners4/pen/XbOxoa
willamgriffin
@willamgriffin
Aug 10 2015 17:59
oh its for all numbers in that range ok well thats different
Bill
@kirah1314
Aug 10 2015 18:05
help reverse
CamperBot
@camperbot
Aug 10 2015 18: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

maxiedk
@maxiedk
Aug 10 2015 18:17
help pairwise
CamperBot
@camperbot
Aug 10 2015 18:17
no wiki entry for: pairwise
:pencil: click here to create one now!after creating your page type update to reload it here
John Chau
@ydjjabt
Aug 10 2015 18:17
anyone want to pair program for the zipline?
techstonia
@techstonia
Aug 10 2015 18:26
is http://codepen.io/AdventureBear/full/yNBJRj working for you guys? I can't see anything except wallpaper, headings and three boxes.
Moisés Man
@moigithub
Aug 10 2015 18:28
do u have any block addon installed on ur browser ?
noscript/adblocker or something like that
Komal Bhandari
@panaroma
Aug 10 2015 18:29
this might be a dumb question but can some one explain me why glove becomes oveglay insteadof lovegay in bonfire pig latin
techstonia
@techstonia
Aug 10 2015 18:30
@moigithub I have adblock installed, but it was working in the morning. Also I just disabled adblock and it still doesn't show
ctcrnitv
@ctcrnitv
Aug 10 2015 18:30
had this idea to scrape a goodreads quotes page and use the scraped data to build an API, is this going to work?
ivanhnavi
@ivanhnavi
Aug 10 2015 18:31
anybody else working on symmetric difference?
techstonia
@techstonia
Aug 10 2015 18:31
@skr5e I don't see any reason it should not
maxiedk
@maxiedk
Aug 10 2015 18:32
@panaroma For words that begin with consonant sounds, the initial consonant or consonant cluster is moved to the end of the word, and "ay" is added (from wikipedia)
Komal Bhandari
@panaroma
Aug 10 2015 18:33
okay so i have to keep moving until i get vowel in the beginning right? @maxiedk
maxiedk
@maxiedk
Aug 10 2015 18:35
@panaroma That's right. I only checked the first two letters.
Michelle
@michelleafleck
Aug 10 2015 18:36
blob
Finally!
maxiedk
@maxiedk
Aug 10 2015 18:38
@michelleafleck best feeling in the world when you figure it out :smile:
Michelle
@michelleafleck
Aug 10 2015 18:39
Actually, I feel kind of stupid for spending so long trying to figure out something that obvious.... @maxiedk
Daniel Neumann
@NeuwDk
Aug 10 2015 18:43
@techstonia same for me, I just put some very simple weather info in all three boxes, because I didn't know what to put there :)
maxiedk
@maxiedk
Aug 10 2015 18:47
@michelleafleck Don't. Next time you'll be faced with a similar problem it will come to you in a jiffy
Stefan Ivic
@stefanivic
Aug 10 2015 18:56

Any easier way to solve this : http://www.freecodecamp.com/challenges/bonfire-check-for-palindromes

function palindrome(str) {
  var trimmed = str.replace(/[^\w]|_/g, "")
         .replace(/\s+/g, " ").toLowerCase();
  var strrB = trimmed.split('').reverse().join();
  var strrA = strrB.replace(/[^\w]|_/g, "")
         .replace(/\s+/g, " ");

  if(strrA !== trimmed){
    return false;
  }
  return true;
}

palindrome("A man, a plan, a canal. Panama");

This is my solution.

Javier
@jalonso087
Aug 10 2015 19:07
I'm having an issue with Bonfire: Check for Palindromes string "A man, a plan, a canal. Panama"
function palindrome(str) {
  // Good luck!
  var newStr = str.toLowerCase();
  newStr = newStr.replace(/!@#$%^&*;()-_=+,.'[]\|}{":?><`~}' /g,"");
  newStr = newStr.replace(/ /g, "");
  var newStr1 = newStr.split("").reverse("").join("");
  if (newStr === newStr1){
    return true;
  }
  else {
    return false;
  }
}



palindrome("eye");
Michelle
@michelleafleck
Aug 10 2015 19:09
@jalonso087 I had this for my regex: (/(\s|\W)+/g, '')
Someone here on the chatroom helped me with that...
Javier
@jalonso087
Aug 10 2015 19:10
Hm, alright thanks! @michelleafleck
Feners4
@Feners4
Aug 10 2015 19:11
how can I add a colored border to my article boxes with @include in http://codepen.io/Feners4/pen/XbOxoa
Michelle
@michelleafleck
Aug 10 2015 19:11
@jalonso087 Somehow I only had one .replace in mine.
Stefan Ivic
@stefanivic
Aug 10 2015 19:11
@jalonso087 I posted my solution 10 sec before you asked. xD
Michelle
@michelleafleck
Aug 10 2015 19:13

Mine was this:
function palindrome(str) {
str = str.replace(/(\s|\W)+/g, '').toLowerCase();
return str === str.split('').reverse().join('');
}
palindrome("eye");

But like I said, someone had to help me with the regex because I wasn't getting anywhere by myself.

Javier
@jalonso087
Aug 10 2015 19:14
@michelleafleck Yeah I was able to replace the two with just one with the solution you gave
@nightwalkerkg Thanks! Looking through your solution as well, I wasn't using RegEx very efficiently
Stefan Ivic
@stefanivic
Aug 10 2015 19:15
But i think my solution could be done better.
Matthew Senko
@mpskierbg
Aug 10 2015 19:15
hey so i have an array [ 1, 2, 3, 5, 2, 1, 4, 2, 1 ] i want to get rid of unique numbers so im left with [ 1, 2, 3, 5, 4, ].
can anybody point me to place to look. i dont really want the anwer just a hint.
Stefan Ivic
@stefanivic
Aug 10 2015 19:16
I did replace twice because it was returning an array to me in the console. For example [brown,fox,jumps,over] and with the reverse instead of being [revo,spmuj, etc] i got it like [over,jumps,fox,brown].
So i had to strip it down second time to get it to brownfoxjumpsover and revospmujxofnworb.
Michelle
@michelleafleck
Aug 10 2015 19:17
@nightwalkerkg it honestly just never occurred to me to do it that way. FCC is pretty much the only coding I've done. Like, ever.
Stefan Ivic
@stefanivic
Aug 10 2015 19:19

@Feners4 http://codepen.io/nightwalkerkg/pen/JdzZXb
Just add

border: 5px solid white;

to the .pin {}

gazzer82
@gazzer82
Aug 10 2015 19:35
Can someone offer some guidance, i am running the following code, but on the second run through reduce the push method fails as for some reason the array is no longer an array, anyone got any ideas/suggestions as to why?
function permAlone(str) {
    return str.split("").reduce(function(returnArr,item,index,array){
      returnArr = returnArr ? returnArr : [];  
      var tempArr = array.slice().splice(index, 1);
      console.log(returnArr instanceof Array);
      return returnArr.push(premGen(tempArr));
  },[]);
}
Michelle
@michelleafleck
Aug 10 2015 19:36

Okay.... my Chunky Monkey is skipping 'c' in the array. I don't know why.

function chunk(arr, size) {
var chunky = [];
for(var i = 0; i < arr.length; i ++) {
chunky.push(arr.slice(i, i += size));
}
return chunky;
}

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

Bill
@kirah1314
Aug 10 2015 19:37
help monkey
CamperBot
@camperbot
Aug 10 2015 19:37

: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 10 2015 19:39
@michelleafleck does this help? ^
Michelle
@michelleafleck
Aug 10 2015 19:40
i think it's starting to, @kirah1314 .
gazzer82
@gazzer82
Aug 10 2015 19:41
On the first loop i can console log the array and it claims to be an array that is an object. On the second iteration it's an object, but not an array.
amwakatsuki
@amwakatsuki
Aug 10 2015 19:41
I don't get what I'm missing in the truncate a string bonfire. I get the error: expect(truncate('A-tisket a-tasket A green and yellow basket', 11)).to.eqls('A-tisket...');expected 'A-tisket a-' to deeply equal 'A-tisket...'
Matthew Senko
@mpskierbg
Aug 10 2015 19:41
function