These are chat archives for FreeCodeCamp/Help

13th
Aug 2015
Lauren
@midori87
Aug 13 2015 00:42
@moigithub thanks!
Jakob
@jarisoft
Aug 13 2015 00:55
Hey guys! don't you ever go to bed??? Well... luckily you don't because I need help doing bonfire optional arguments... I've got a solution but test expect(add(2)(3)).to.equal(5);
expected 6 to equal 5 doesn't go through
CamperBot
@camperbot
Aug 13 2015 00:55
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Nic Galluzzo
@ngalluzzo
Aug 13 2015 00:59
took a dictionary approach to the Inventory Update bonfire.. what do you guys think?
function inventory(arr1, arr2) {
    // All inventory must be accounted for or you're fired!
  var Inventory = {};
    arr1.concat(arr2).map(function(item) {
      var itemName = item[1];
      var itemQty = item[0];
      if (!Inventory[itemName]) {
        Inventory[itemName] = itemQty;
      }
      else {
        Inventory[itemName] += itemQty;
      }
    });

  var inventoryMap = [];
  for (var i in Object.keys(Inventory)) {
    inventoryMap.push([Inventory[Object.keys(Inventory)[i]], Object.keys(Inventory)[i]]);
  }

  return inventoryMap.sort(function(a,b) {
    return a[1] > b[1];
  });
}
HelooBlorld
@qzoxec
Aug 13 2015 01:04
ANybody here can help with Bonfire: Seek and Destroy?
CamperBot
@camperbot
Aug 13 2015 01:04
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Jakob
@jarisoft
Aug 13 2015 01:09
@quoxec you could use filter
Alex Marrufo
@AlexMarrufo
Aug 13 2015 01:13
I'm having trouble on making an image smaller.. not too sure where to put it .smaller-image { width: 100px; }
HelooBlorld
@qzoxec
Aug 13 2015 01:14
@jarisoft I tried but I think I am misunderstanding it'suse
function destroyer(arr) {

  for (var i = 1; i<arguments.length; i++){
    //return arguments[i]; works
    arr = arr.filter(function(val) {
      return val != arguments[i];
});
  }
  // Remove all the values
  return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Jakob
@jarisoft
Aug 13 2015 01:17
@qzoxec thats quite good already but you need to apply the functions to all aguments[i] for i > 0 to the array at arguments[0]
Was that a clear answer or do you need more details?
HelooBlorld
@qzoxec
Aug 13 2015 01:22
@jarisoft I should have noted that I corrected the middle section of the for loop to read <= - which I believe should iterate through all the arguments after arr?
Jakob
@jarisoft
Aug 13 2015 01:23
I walk you through but leave the implmentation to you
arguments holds an array at pos 0
HelooBlorld
@qzoxec
Aug 13 2015 01:24
Yes I understand that part
Marceia Egler
@megler
Aug 13 2015 01:25
@AlexMarrufo - the .smaller-image { width: 100px; } goes in your CSS, you call the .smaller-image in your HTML in the <img> tag. Does that help?
Jakob
@jarisoft
Aug 13 2015 01:26
``` initialArray.filter(function(value ) { for (var i = 0; i < removables.length; i++) {
if (value === removables[i]) {
return false;
}
}
return true;});
Marceia Egler
@megler
Aug 13 2015 01:27
.smaller-image {width: 100px;
}
.red-text {
color: red;
}
h2 {
font-family: Lobster, Monospace;
}
p {
font-size: 16px;
font-family: Monospace;
}
</style>
then the image html would be something like <img src = "" class="smaller-image"/>
CamperBot
@camperbot
Aug 13 2015 01:27
:bulb: to format code use backticks! ``` more info
Jakob
@jarisoft
Aug 13 2015 01:27
initialArray is the first argument and you apply the filter function that checks if the current value is iniside the removables
Liz Rezes
@queenlizo
Aug 13 2015 01:29
Any idea why this is returning NaN, and not returning the sum of all the odd numbers in a Fibanacci sequence?
function sumFibs(num) {
    var fibArr = [],
    i = 0,
    j = 1;

    fibArr.push(i);
    fibArr.push(j);

    while (fibArr.length <= num) {
        fibArr.push(fibArr[j] + fibArr[i]);
        j++;
        i++;
    }
    var sum = 0;
    for (k=0; k<=fibArr.length; k++) {
        if (fibArr[k]%2 !== 0) {
            sum = fibArr[k] + fibArr[k];
        }
    }
   return sum;
}

sumFibs(4);
Alex Marrufo
@AlexMarrufo
Aug 13 2015 01:31
Im not good with the terminology yet.. but I think I'm having trouble with the HTML where exactly do I put this? <img src=""
@megler
Nic Galluzzo
@ngalluzzo
Aug 13 2015 01:31
is k defined there?
HelooBlorld
@qzoxec
Aug 13 2015 01:32
@jarisoft I am not following, in the Bonfire example is your initialarray referring to arr, and what is "removables"?
Jakob
@jarisoft
Aug 13 2015 01:32
@queenlizo you also need to sum += fibArr...
Liz Rezes
@queenlizo
Aug 13 2015 01:33
@jarisoft umm.... that's in the if statement?
Jakob
@jarisoft
Aug 13 2015 01:34
@qzoxec I created those arrays first before I used them initialArray = arguments[0] and using a forloop to push all other arguments into removables. initialArray and removables are just my own names.. call those arrays x,y or blah
Marceia Egler
@megler
Aug 13 2015 01:35

It's ok, @AlexMarrufo . This same conversation is going on over on the regular FreeCodeCamp chat. @dnorthrupva summed it up like this:

So in your "<img src='https://bit.ly/fcc-kittens'/>" change it to <img class="smaller-image" src='https://bit.ly/fcc-kittens'/>
Without the "class" on it, it will never re-direct to your CSS to get it's resizing.
And '.smaller-image' means "CSS. Go find the class 'smaller-image' (The . means a class # means an id) and do { } to it.

Liz Rezes
@queenlizo
Aug 13 2015 01:37
@jarisoft thanks!
Alex Marrufo
@AlexMarrufo
Aug 13 2015 01:38
well that was easy.. seems like I'm going to have a love/hate relationship with this.. anyone else lol
Marceia Egler
@megler
Aug 13 2015 01:39
I'm plowing through javascript now. Yes, the love/hate is alive and well. LOL. Best of luck!
Alex Marrufo
@AlexMarrufo
Aug 13 2015 01:41
I'll probably be back soon haha thanks!
HayleeNeal
@HayleeNeal
Aug 13 2015 01:43
Can I get help with html5 css waypoint 17? please? I am having a lot of trouble overiding the css with !important. It looks like I have everything but" Your h2 element should be red." correct. I have no idea how to post my stuff on here for everyone to see, I'm brand new :( and having a lot of difficulty
SojournerOctocat
@SojournerOctocat
Aug 13 2015 01:45
@HayleeNeal What's the URL/link?
Donavin Northrup
@dnorthrupva
Aug 13 2015 01:45
So all you do to override it is type "color: red !important". if you want to PM me I can help.
Robert
@rc242
Aug 13 2015 01:45
heyo!
HayleeNeal
@HayleeNeal
Aug 13 2015 01:45
@dnorthrupva thanks :) I'll pm you
Jakob
@jarisoft
Aug 13 2015 01:46
@qzoxec did you work it out?
HelooBlorld
@qzoxec
Aug 13 2015 01:49
@jarisoft no this is killing me 4 days I have been trying to figure this out
I think you are saying I need to create the function that go into the filter separately
How to get the function and the arguments variable into it?
here's what I have:
function destroyer(arr) {
  var newArr = arr;
  var toEval = function(val, compare){
    return val != compare;
  };
  for (var i = 1; i<=arguments.length; i++){
    //return arguments[i]; works
    newArr = newArr.filter(toEval, ////????
                           {

}
  }
  // Remove all the values
  return newArr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
I have been reading documentation but this filter function has me totally stumped
Luis Felipe López G.
@luishendrix92
Aug 13 2015 01:52
This message was deleted
wiki js ternary
CamperBot
@camperbot
Aug 13 2015 01:52

:point_right: js ternary [wiki]

The Ternary operator replaces an if/then block.

It's mostly used in one liners for simple tests and replacements, like this:

var x = false;
var s = x ? "yes" : "no";
console.log(s);  //→ "no"

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

SojournerOctocat
@SojournerOctocat
Aug 13 2015 01:53
@qzoxec Maybe you could put the for statement in the filter statement.
HelooBlorld
@qzoxec
Aug 13 2015 01:57
@SojournerOctocat Does my toEval function look right?
SojournerOctocat
@SojournerOctocat
Aug 13 2015 02:00
I don't know. I solved it a little differently. I didn't use a function besides destroyer.
HelooBlorld
@qzoxec
Aug 13 2015 02:01
@SojournerOctocat did you use filter?
SojournerOctocat
@SojournerOctocat
Aug 13 2015 02:01
@qzoxec Yes. I had a filter statement containing a for statement.
Cody Bouscaren
@codybousc
Aug 13 2015 02:04
Hey all, this is kind of silly but I just started messing around with the DOM and am having some issues. I created a few variables capturing different portions of the html and just want to 'console.log' them. Each time I try though, the console logs the objects as empty even though they definitely have content. Here are a couple of examples
var imgDom = document.getElementsByTagName("li");
console.log(imgDom);

var mainContent = document.getElementById("main_content");
console.log(mainContent);

var imagesish = document.getElementById("images");
console.log(imagesish);
any advice? am i doing something wrong?
and here's the html
<html>
  <head>

    <link rel="stylesheet" href="css/styles.css" media="all" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="playScript.js"></script>
  </head>
  <body>

    <div id="main_content">
      <p>Yumyumnumnum</p>
    </div>

        <ul id="images">

          <li><img src="https://images.unsplash.com/photo-1437623889155-075d40e2e59f?q=80&fm=jpg&s=51e3e297c2171808e0610d00b970bf7b"</li>

          <li><img src="https://images.unsplash.com/photo-1431578500526-4d9613015464?q=80&fm=jpg&s=169b4f4e6f3882a03b6b93b2e6848052"</li>

          <li><img src="https://images.unsplash.com/photo-1433733071959-30cd185d14a8?q=80&fm=jpg&s=2bb5c5d8e0b1e5a0c994fc660681348e"</li>

          <li><img src="https://images.unsplash.com/photo-1434139240289-56c519f77cb0?q=80&fm=jpg&s=13f8a0d1c2f96b5f311dedeb17cddb60"</li>
        </ul>

  </body>
</html>
DTing
@dting
Aug 13 2015 02:11
@codybousc move <script src="playScript.js"></script> to the end of your body and you'll see different results
Cody Bouscaren
@codybousc
Aug 13 2015 02:12
@dting that works!
why is that?
DTing
@dting
Aug 13 2015 02:12
you also arent closing your img tags.
Cody Bouscaren
@codybousc
Aug 13 2015 02:13
yikes, yeah that was a recent change. i added the <li>s in hopes of making the DOM selectors work
why does moving the js script to the bottom of the body change things?
Liz Rezes
@queenlizo
Aug 13 2015 02:14
Any one know why the while statement is creating an array of [ 0, 1, 1, 2, 3, 5, 8 ] when I want it to be [ 0, 1, 1, 2, 3, 5]? Thanks!
function sumFibs(num) {
    var fibArr = [],
    i = 0,
    j = 1;

    fibArr.push(i);
    fibArr.push(j);

    while (fibArr.length <= num) {
        fibArr.push(fibArr[j] + fibArr[i]);
        j++;
        i++;
    }
    console.log(fibArr-i);

    var total = 0;
    for (var k = 0; k <= fibArr.length; k++) {
        if (k%2 !== 0) {
       // return num + fibArr[k];
        }
    }

}

sumFibs(6);
DTing
@dting
Aug 13 2015 02:15
@codybousc because your script is executing before you document is ready.
@queenlizo before the code in the while loop runs and pushes the 7th item it is true.
so the code inside runs and you end up with 7 items
Liz Rezes
@queenlizo
Aug 13 2015 02:18
@dting ok.thanks and let me work on that some more
Moisés Man
@moigithub
Aug 13 2015 02:20
u no need to generate "num" length array.. but whatever FIBnum <= num @queenlizo
Cody Bouscaren
@codybousc
Aug 13 2015 02:21
@dting would wrapping all of the js in the $(document).ready(function)... deal do the same thing?
thanks for the help, by the way!
Liz Rezes
@queenlizo
Aug 13 2015 02:22
@moigithub Hmm... I guess I'm not understanding
DTing
@dting
Aug 13 2015 02:22
@codybousc not the same thing but that is probably what you want to do.
Moisés Man
@moigithub
Aug 13 2015 02:22
lemme paste a fibnum sequence...
@queenlizo
0,1,1,2,3,5,8,13,21,34,55,89,144
so lets.. say.. u want
sumFibs(144);
u no need to generate and push 144 numbers to ur array
DTing
@dting
Aug 13 2015 02:24
bf sum all odd fib
CamperBot
@camperbot
Aug 13 2015 02:24

:fire:Bonfire: Sum All Odd Fibonacci Numbers :link:

function sumFibs(num) {
  return num;
}

sumFibs(4);

Return the sum of all odd Fibonacci numbers up to and including the passed number if it is a Fibonacci number.

more info:  bf details | bf links | hint

DTing
@dting
Aug 13 2015 02:24
bf details
CamperBot
@camperbot
Aug 13 2015 02:24

:fire:Bonfire: Sum All Odd Fibonacci Numbers :link:

function sumFibs(num) {
  return num;
}

sumFibs(4);
Return the sum of all odd Fibonacci numbers up to and including the passed number if it is a Fibonacci number.
The first few numbers of the Fibonacci sequence are 1, 1, 2, 3, 5 and 8, and each subsequent number is the sum of the previous two numbers.
As an example, passing 4 to the function should return 5 because all the odd Fibonacci numbers under 4 are 1, 1, and 3.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.
links:
Moisés Man
@moigithub
Aug 13 2015 02:25
@queenlizo on that example.. 13 numbers will be enough to reach 144 (wich its the num requesting on the example ) sumFibs(144);
Liz Rezes
@queenlizo
Aug 13 2015 02:25
@moigithub ok. thanks!
@moigithub but if I have 143 in there, I don't want 144 to be added in there. How do I do that?
Moisés Man
@moigithub
Aug 13 2015 02:26
"Return the sum of all odd Fibonacci numbers up to and including the passed number"
the exercise require the 144 num to be sum
so its <=
if u dont wanna include should be <
DTing
@dting
Aug 13 2015 02:26
thats a bad example. 144 is even =P
hah
Moisés Man
@moigithub
Aug 13 2015 02:27
ahh.. forgot the ODD only part :D
Liz Rezes
@queenlizo
Aug 13 2015 02:27
I've got the odd only part down
Moisés Man
@moigithub
Aug 13 2015 02:27
well combine whatever i said + only ODD Fibnums and u have it :P
Liz Rezes
@queenlizo
Aug 13 2015 02:29
@moigithub OK. Thanks!
Cody Bouscaren
@codybousc
Aug 13 2015 02:29
@dting ok, thanks again!
DTing
@dting
Aug 13 2015 02:29
@codybousc nps
HelooBlorld
@qzoxec
Aug 13 2015 02:30
@SojournerOctocat @jarisoft Here's what I came up with, but it is only catching the "2", which is the first undefined argument
function destroyer(arr) {
  var argsArr = [];
  for (var i = 1; i<arguments.length; i++){
    argsArr.push(arguments[i]);
  }
  //return argsArr; returns [2,3]
  var newArr = arr;
  newArr = newArr.filter(function(val){
    for (var i = 0; i<=argsArr.length; i++){
      if( val === argsArr[i]){
        return false;
    }
      else {
        return true;
      }
     }}
    );

  return newArr;
}


destroyer([1, 2, 3, 1, 2, 3], 2, 3);
it returns [1,3,1,3]
DTing
@dting
Aug 13 2015 02:33
@qzoxec you need to move your return true outside of that forloop. otherwise the first non match you get it will tell your filter function to include that element, bypassing the check for the other arguments.
SojournerOctocat
@SojournerOctocat
Aug 13 2015 02:37
@qzoxec, @dting's right. You don't need the else statement.
HelooBlorld
@qzoxec
Aug 13 2015 02:40
@dting @SojournerOctocat I removed the else statement entirely which returns an empty array. Where should the true statement go if it's not contingent on the if/else?
DTing
@dting
Aug 13 2015 02:41
@qzoxec you need the return true after the for statement
basically saying "after i check all my arguments is the condition is not false. then i want to include this element"
HelooBlorld
@qzoxec
Aug 13 2015 02:44
@dting it worked but I still don;t understand it unfortunately, thank you for your help though
this Bonfire has been exceptionally challenging for some reason and I am really discouraged by it.
DTing
@dting
Aug 13 2015 02:45
and alternative would be to create a hash object rather than an array. Since you are already creating an argsArr you could instead do:
function destroyer(arr) {
  var args = Object.create(null);
  for (var i = 1; i<arguments.length; i++){
    args[arguments[i]] = true;
  }

  var newArr = arr.filter(function(val){
    return !(val in args);
  });

  return newArr;
}
@qzoxec okay let me try to give a better explanation of your solution.
DTing
@dting
Aug 13 2015 02:51
function destroyer(arr) {
  var argsArr = [];
  for (var i = 1; i<arguments.length; i++){
    argsArr.push(arguments[i]);
  }
  var newArr = arr.filter(<function that tells you if your elements of "arr" are in "argsArr">);
  return newArr;
}
You need to replace the function that filter calls with a function that tells you if an element is in the argsArr.
Initially you had:
function(val) {
  for (var i = 0; i < argsArr.length; i++){
    if (val === argsArr[i]) {
      return false;
    } else {
      return true;
    }
  }
}
Christopher Stewart
@cjstewart13
Aug 13 2015 02:54
I'm on the factorizing bonfire and am having a difficult time getting the for loop to record each item of the loop in order to multiply each instance of the loop
HelooBlorld
@qzoxec
Aug 13 2015 02:55
@dting Thanks again, I will review tomorrow. I just completed the next Bonfire in under 5 minutes so feel better, but I literally spect the past 4 days on the filter bonfire and still struggle to comprehend. Maybe they should explain it a little more or maybe I just have a block on that particular function
Brett Guillory
@kurzninja
Aug 13 2015 02:55
Is the Bootstrap CDN down or something?
DTing
@dting
Aug 13 2015 02:55
The problem is it will always return a value after checking the first element.
Luis Felipe López G.
@luishendrix92
Aug 13 2015 02:56

My solution for search and replace:

function replace(str, before, after) {
  return str.replace(new RegExp(before,"ig"),function(toReplace) {
    if (toReplace.charCodeAt(0) < 97)
      return after[0].toUpperCase() + after.slice(1);
    else
      return after;
  });
}

replace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");

I'm really really loving new RegExp()

Sean
@seanr707
Aug 13 2015 02:56
@kurzninja on CodePen?
Brett Guillory
@kurzninja
Aug 13 2015 02:56
Yeah
I just got back to my computer and all of a sudden everything stopped working
Sean
@seanr707
Aug 13 2015 02:57
@kurzninja Must be b/c I was having the same problem
Brett Guillory
@kurzninja
Aug 13 2015 02:57
ok good, so it's not me
SojournerOctocat
@SojournerOctocat
Aug 13 2015 02:57
@qzoxec I had the similar issues with solving Seek and Destroy.
HelooBlorld
@qzoxec
Aug 13 2015 02:57
@dting I am really too brain dead to try this anymore tonight, but thanks for help and I will surely be relying on you in future :)
Sean
@seanr707
Aug 13 2015 02:57
No, something has messed up and the computer is looking to your computer instead of their server for bootstrap
HelooBlorld
@qzoxec
Aug 13 2015 02:58
@SojournerOctocat Thanks for help too, hopefully understanding will come
Brett Guillory
@kurzninja
Aug 13 2015 02:58
No, it's trying to access the bootstrap cdn and it's failing
Sean
@seanr707
Aug 13 2015 02:59
ah, i see now, the cdn fails then it looks at the local machine for a local copy
DTing
@dting
Aug 13 2015 03:02
@luishendrix92 I think your solution would work with out regex
Regexp
Luis Felipe López G.
@luishendrix92
Aug 13 2015 03:10
@dting It will, if I'd want to account for "jUmPeD" I could compare uppercase after with uppercase before.
But I just love using RegExp D:
DTing
@dting
Aug 13 2015 03:11
@luishendrix92 ya the instructions are kinda unclear if that should be matched or not. That challenge isn't clear and the test cases don't clarify the intent.
Brett Guillory
@kurzninja
Aug 13 2015 03:12
Can anyone take a look at my Codepen and tell me why my Twitter button doesn't appear to be updating?
http://codepen.io/kurzninja/pen/qdLYwX
Luis Felipe López G.
@luishendrix92
Aug 13 2015 03:12
Also, there is this issue where the user might want to replace "I like turtlenecks" with "I like dognecks" haha. Though I'm not sure to what point replace() would help with that without regexp.
Brett Guillory
@kurzninja
Aug 13 2015 03:13
Or why it doesn't throw a quote in there automatically after the page loads?
DTing
@dting
Aug 13 2015 03:21
@kurzninja you have some async issues.
Brett Guillory
@kurzninja
Aug 13 2015 03:22
@dting Yeah, I figured, but I don't know what to do, this is still new to me
It's this getJSON() function that's been killing me for days now
DTing
@dting
Aug 13 2015 03:25
@kurzninja the easy way to do it is if you need the information that is returned from that getJSON call for something, use it from inside the callback.

so

    renderQuote(currentQuote);    
    updateTwitterButtonHREF(currentQuote['body']);
    console.log(quotesArray.length);

should all be called from inside the callback function of the getJSON

Brett Guillory
@kurzninja
Aug 13 2015 03:26
damn
that's gonna be tough
because it has to be called from the click event
let me think about this
what I'm trying to do is cache a bunch of quotes into an array so I'm not making an API call with every click
is that stupid?
DTing
@dting
Aug 13 2015 03:31
@kurzninja okay i just looked a little closer at your code. No that's fine.
Brett Guillory
@kurzninja
Aug 13 2015 03:33
What I'm trying to have happen is the page loads, the quotes are fetched and cached in the quotesArray, then the first quote is shift()'ed and rendered on the page
also the Twitter button href is updated
then all that also happens again when the button is pressed
popping quotes off the array until it's empty, then making another fetch to fill it again
I keep getting undefined errors on my first clicks but not the rest so I know that there's definitely async issues
Adam Rehard
@adamrehard
Aug 13 2015 03:35
This message was deleted
Brett Guillory
@kurzninja
Aug 13 2015 03:36
@adamrehard just a tip, it'd be easier to type if you were trying to match
![aeiou] instead of matching the rest of the alphabet
Adam Rehard
@adamrehard
Aug 13 2015 03:37
Try #2... This is the pig latin bonfire, and it's returning "str.push is not a funtion"
function translate(str) {
  var cons_re = /b|c|d|f|g|h|j|k|l|m|n|p|q|r|s|t|v|w|x|y|z/;
  var first_letter = '';
  var cut_str = '';
  var final_str = '';


  str.split('');

  if(str[0].match(cons_re)){
    first_letter = str.substr(0,1);
    str = str.substr(1);


    // WORKS TIL HERE
    str.split('');
    str.push(first_letter, "a", "y");
    str.join();

  } else {
    cut_str.split('');
    str.push("w", "a", "y");

    str.join();

  }



  return str;
}

translate("consonant");
@kurzninja , thanks, I'll fix that
Brett Guillory
@kurzninja
Aug 13 2015 03:38
no worries :)
I think it's because your string is already an array at that point
Adam Rehard
@adamrehard
Aug 13 2015 03:38
Ohh, I see. I'll try that.
Sean
@seanr707
Aug 13 2015 03:39
str.substr(1, str.length-1)
Brett Guillory
@kurzninja
Aug 13 2015 03:39
you split it above that, then you split it again inside the if
Sean
@seanr707
Aug 13 2015 03:40
The .split and .push won't save, you need to do
str = str.split('');
str = str.push(...);
str = str.join('');
Brett Guillory
@kurzninja
Aug 13 2015 03:41
ahhh
yes
split and join are non-mutating
they're returning
Luis Felipe López G.
@luishendrix92
Aug 13 2015 03:42
@adamrehard You should consider asking the program Are there vowels? instead of Are there consonants?. It's shorter to write /[aeiou]/i than all of the consonants and typing | after each consonant inside the regular expression.
Brett Guillory
@kurzninja
Aug 13 2015 03:42
@luishendrix92 I suggested that above too
less prone to error too, easier to type [aeiou] and see that they're all there than the rest of the alphabet
Luis Felipe López G.
@luishendrix92
Aug 13 2015 03:45

I just finished that bonfire too, here's my sol:

function translate(str) {
  var consonants = str.match(/^[^aeiou]+/i);
  if ( /[aeiou]/i.test(str[0]) )
    return str + 'way';
  else
    return str.slice(consonants[0].length) + consonants[0] + 'ay';
}

translate("consonant");

Now I want to write a different solution using String.replace() and capturing groups

Adam Rehard
@adamrehard
Aug 13 2015 03:50
Thanks! I didn't know that '+' concatenated strings in JS :)
DTing
@dting
Aug 13 2015 03:52
@kurzninja So as far as your tweet button. I don't think its possible to use twitter's widget and dynamically change the contents. It uses an iframe. I believe you need to craft your own button. There are some stack overflow questions related to that issue.
@kurzninja The other async issue, you can do it this way.
  function getQuotes(url) {
    return $.getJSON(url).done(fillQuotesArray);
  }
Brett Guillory
@kurzninja
Aug 13 2015 03:53
damn, I thought it would be as simple as changing the HREF of the button
DTing
@dting
Aug 13 2015 03:53
make your getQuotes return the promise.
Brett Guillory
@kurzninja
Aug 13 2015 03:53
I think I tried that before but it wasn't working properly
but at the time I wasn't using .done()
maybe that'll do it
DTing
@dting
Aug 13 2015 03:54
then do something like this:
  function newQuote() {
    quotesArray.length ? setNextQuote() : getQuotes(currentURL).then(setNextQuote);
  }

  function setNextQuote() {
    currentQuote = quotesArray.shift();
    renderQuote(currentQuote);
    updateTwitterButtonHREF(currentQuote['body']);
  }

  $('.getquote').click(newQuote); // .getquote .click 

  newQuote();
Brett Guillory
@kurzninja
Aug 13 2015 03:55
I'll have to read the documentation better on .then and whatnot
HayleeNeal
@HayleeNeal
Aug 13 2015 03:57

  div 
  .gray-background 
   {
     background-color: gray; 
   }

</style>

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

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

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

<div class='gray-background'>
What am I doing wrong here? I'm supposed to give my div class a gray background in the css style. I'm sure it's something small :(
Brett Guillory
@kurzninja
Aug 13 2015 03:57
where's your div closing tag?
Robert
@rc242
Aug 13 2015 03:58
heyo.
HayleeNeal
@HayleeNeal
Aug 13 2015 03:58
down below the <ol> that's just under the code in the pic
 <p>Things cats love:</p>
  <ul>
    <li>cat nip</li>
    <li>laser pointers</li>
    <li>lasagna</li>
  </ul>
  <p>Top 3 things cats hate:</p>
  <ol>
    <li>flea treatment</li>
    <li>thunder</li>
    <li>other cats</li>
  </ol>
</div>
Brett Guillory
@kurzninja
Aug 13 2015 03:59
ok, so it's not empty
Matt Everson
@matteverson
Aug 13 2015 03:59
<style> should be inside <head>
not <body>
Brett Guillory
@kurzninja
Aug 13 2015 03:59
aye ^^^^
HayleeNeal
@HayleeNeal
Aug 13 2015 04:01
I just put in the <head></head> and it didn't fix the issue.
Brett Guillory
@kurzninja
Aug 13 2015 04:02
get rid of the div declaration in the style and just leave .gray-background
HayleeNeal
@HayleeNeal
Aug 13 2015 04:03
That worked! Thanks so much!
Brett Guillory
@kurzninja
Aug 13 2015 04:04
I think the way you had it typed was screwing up the processing of it
I don't think you can separate your CSS onto different lines like that
HayleeNeal
@HayleeNeal
Aug 13 2015 04:05
Ahh good to know, I don't know why I was separating it
Brett Guillory
@kurzninja
Aug 13 2015 04:06
glad I helped :)
Adam Rehard
@adamrehard
Aug 13 2015 04:14
Take 3! The glove test is failing, and I have no idea of an elegant way to match glove...
function translate(str) {
  var cons_re = /^[^aeiou]+/;
  var first_letter = '';
  var cut_str = '';

  str = str.split('');

  if(str[0].match(cons_re)){
    str = str.join('');
    first_letter = str.substr(0, 1);
    cut_str = str.substr(1, str.length-1);

    return cut_str + first_letter + 'ay';

  } else {
    str = str.join('');
    return str + 'way';
  }

}

translate("paragraphs");
Luis Felipe López G.
@luishendrix92
Aug 13 2015 04:16
@adamrehard You can work with your cons_re you could capture gl and check for its length, return from index 2 of str + gl + 'ay'
Making it oveglay
index 2 because that's the length of gl
Adam Rehard
@adamrehard
Aug 13 2015 04:18
Got it. ended up cheating, but it runs...
Brett Guillory
@kurzninja
Aug 13 2015 04:28
@dting I tried what you said, but now it's not working at all
weird the preview doesn't run.
Brett Guillory
@kurzninja
Aug 13 2015 04:31
weird
but damn you
it works lol
there's still an undefined variable being console logged when the window loads though
I think it's from the Twitter Button function
DTing
@dting
Aug 13 2015 04:32
ya it is
Philosoraptor1981
@Philosoraptor1981
Aug 13 2015 04:32
function where(arr, num) {
  var index = 0;
  for(var key in arr){
    if(num <= arr[key] ){
      index = key;
    }

  }
  return index;
}


where([40, 60], 50);
Brett Guillory
@kurzninja
Aug 13 2015 04:33
hmmm
weird
I had this
function newQuote() {
        quotesArray.length ? setNextQuote() : getQuotes(currentURL).then(setNextQuote());
    }
Philosoraptor1981
@Philosoraptor1981
Aug 13 2015 04:34
Well I had it originally returning in the loop but someone said "Don't do that you want to loop through all the keys"
Brett Guillory
@kurzninja
Aug 13 2015 04:34
but that didn't work until i wrapped setNextQuote() in an anonymous function inside then .then(), why?
DTing
@dting
Aug 13 2015 04:34
just take off the ()
Brett Guillory
@kurzninja
Aug 13 2015 04:35
oh
i see
DTing
@dting
Aug 13 2015 04:35
then will call the function you pass to it. if you have the () the callback is the result of calling the intended function. ya
Brett Guillory
@kurzninja
Aug 13 2015 04:35
right
genius
thanks
Philosoraptor1981
@Philosoraptor1981
Aug 13 2015 04:35
Thank you!!! @ "+Key"
for some reason I can see notfications for people talking to me...but I can't see them in the main chat
does anyone know why that would be?
Brett Guillory
@kurzninja
Aug 13 2015 04:36
so now everything is running "inside" the async callback, right?
DTing
@dting
Aug 13 2015 04:36
@Philosoraptor1981 i dont see anyone talking to you
Philosoraptor1981
@Philosoraptor1981
Aug 13 2015 04:36
I know you don't
but I do!
But not here
Brett Guillory
@kurzninja
Aug 13 2015 04:37
You might have it set to give notifications for all messages instead of just mentions to you
click the settings button in the top right
and click Notifications
see what it's set to
Logan Tegman
@ltegman
Aug 13 2015 04:37
@Philosoraptor1981 I’ve recieved some glitchy messages to me I could never find before. I just cleared them out and ignored them :P
Brett Guillory
@kurzninja
Aug 13 2015 04:37
you have to set that setting per room, which is a pain :\
Philosoraptor1981
@Philosoraptor1981
Aug 13 2015 04:39
Nvm it was coming from a different room
Brett Guillory
@kurzninja
Aug 13 2015 04:51
lol
Cory Johnson
@CygnusSW
Aug 13 2015 05:10
Quick question, or poll, rather. Would it be harmful to take a break from the basic bon fires and do the lessons from object oriented java script?
basic bonfires being the basic algorithms
Brett Guillory
@kurzninja
Aug 13 2015 05:13
@Cory2911 you can try
worst that can happen is you don't understand something, in which case just go back to what you were doing and try again later :)
Robert
@rc242
Aug 13 2015 05:15
The basic bonfires are there to re-enforce what you should have learned.
David Vaughan-Brown
@dvaun
Aug 13 2015 05:52
question: I'm close to the bonfires and I am unsure if I can get Screen Hero to run through Wine/Winetricks on my OS (I use a linux distro, Uberstudent). Does anyone know of any linux users that have run into the same issue with pair programming?
Luis Felipe López G.
@luishendrix92
Aug 13 2015 05:54
@dvaun Linux users use other tools, not sure if teamviewer works in Linux, some use kobra or coderpad.
David Vaughan-Brown
@dvaun
Aug 13 2015 05:55
gotcha, thanks for the quick response @luishendrix92
Alex Litel
@alexlitel
Aug 13 2015 05:58
Can someone help with the DNA pairing bonfire? I'm completely lost.
CamperBot
@camperbot
Aug 13 2015 05:58
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Bill
@kirah1314
Aug 13 2015 06:00
help dna
CamperBot
@camperbot
Aug 13 2015 06:00
no wiki entry for: dna
:pencil: click here to create one now!after creating your page type update to reload it here
Bill
@kirah1314
Aug 13 2015 06:00
@alexlitel what issues are you having with DNA bonfire?
Alex Litel
@alexlitel
Aug 13 2015 06:01
Beyond creating a 2D array to pair each letter with another missing letter, I'm not sure how to tackle it.
Bill
@kirah1314
Aug 13 2015 06:03
you mean you're not sure how to create a 2D array?
Alex Litel
@alexlitel
Aug 13 2015 06:04
No.
Bill
@kirah1314
Aug 13 2015 06:04
or you're not sure what the bonfire is asking to do?
Ray McMahan
@arxene
Aug 13 2015 06:04
@dvaun Here's TeamViewer's installs page for Linux. I don't know what Uberstudent is, but if it's based off one of the listed distros maybe TeamViewer will work.
Bill
@kirah1314
Aug 13 2015 06:04
click the run code and it shows you what you're trying to achieve @alexlitel
assert.deepEqual(pair("ATCGA"),[['A','T'],['T','A'],['C','G'],['G','C'],['A','T']], 'should return the dna pair');should return the dna pair: expected 'ATCGA'
Alex Litel
@alexlitel
Aug 13 2015 06:05
Yes, I did that, but I'm not sure how it wants me to get to the solution
Bill
@kirah1314
Aug 13 2015 06:06
@alexlitel ah ok, the bonfire is asking you to basically pair each letter from str
str = "GCG" so your expected output is [['G','C'],['C','G'],['G','C']]
if str is "ATA" then your output is [['A','T'],['T','A'],['A','T']]
don't worry about what these letters mean, unless you want to read up about DNA. Just have to pair them up like above ^
Kyle Kinzalow
@KyleKinz
Aug 13 2015 06:18
I seem to always have to click "I've completed this challenge" 2-3 times after a challenge. Anyone else have this issue?
Luis Felipe López G.
@luishendrix92
Aug 13 2015 06:29

Jesus bloody christ godness me, I finished DNA pairings after spending a lot of time trying to figure out how to avoid using switch() or many if statements. Here's what I came up with:

function pair(str) {
  var pairings = {A: ["A", "T"], T: ["T", "A"], C: ["C", "G"], G: ["G", "C"]};
  return str.match(new RegExp("[" + Object.keys(pairings).join('') + "]", "g"))
  .map(function(pairing) { return pairings[pairing]; });
}

pair("GCG");

Maybe I'll use the same solution for the HTML entities :) so happy I am with myself right now.

Jen
@calaminejen
Aug 13 2015 07:21
hello everyone, I'm having some trouble with Title Case. Here is my code so far. I suspect I need something other than push, or something after it that presents the contents of the array rather than the digits. my output is [0,1,2,3,4].
function titleCase(str) {
  stringArray = str.split(' ');
  var capsArray = [];
  for (var word in stringArray) {
    capsArray.push(word.charAt(0).toUpperCase() + word.slice(1).toLowerCase());
  }
  capString = capsArray.join(' ');
  return capString;
}

titleCase("I'm a little tea pot");
Sergey Zhidkov
@sergey-zhidkov
Aug 13 2015 07:33
@calaminejen for ... in ... works with arrays in a way you didn't expect
@calaminejen use forEach or just usual for loop
Roy
@CruelCoin
Aug 13 2015 07:42
@calaminejen I edited your code, and my solution has a for loop. Starting i at 0, and looping through the length of the stringArray.
Changing the for loop means also having to redefine "word". Use the charAt of stringArray[i] in your push. Same thing with your slice.
I also changed slice for substr, but meh.
@calaminejen @sergey-zhidkov Aye, according to this: http://www.pythontutor.com/ Cal's array was filling up with numbers "1,2,3,4"
Angel Sanchez
@ASanchez26
Aug 13 2015 08:03
For the Smallest Common Multiple bonfire, is there a more efficient way than iterating through 27, 000 +1 increments ?
Mistereo
@Mistereo
Aug 13 2015 08:06
@ASanchez26 where are you get this number? (27,000 + 1)
Angel Sanchez
@ASanchez26
Aug 13 2015 08:08
The smallest common multiple for all numbers between 1 and 13 is 360,360. That's 13 x 27,720
Mistereo
@Mistereo
Aug 13 2015 08:09
@ASanchez26 hhm, didn't get it :) Can you copy/paste your code?
John Behan
@jjmax75
Aug 13 2015 08:09
Hi guys, can anyone clarify something for me on the Symmetric Difference Bonfire?
Mistereo
@Mistereo
Aug 13 2015 08:14
@ASanchez26 time complexity of my solution: ~ O(log(max(a,b)) * |a - b|), if you familiar with big O notation.
Angel Sanchez
@ASanchez26
Aug 13 2015 08:15
@Mistereo Heh, unfortunately, I am not.
Jen
@calaminejen
Aug 13 2015 08:15
thank you, @sergey-zhidkov and @CruelCoin ! that helped.
CamperBot
@camperbot
Aug 13 2015 08:15
calaminejen sends brownie points to @sergey-zhidkov and @cruelcoin :sparkles: :thumbsup: :sparkles:
hey @calaminejen if you found this info helpful :point_right: consider adding a wiki article!
Mistereo
@Mistereo
Aug 13 2015 08:16
@jjmax75 what's your problem?
John Behan
@jjmax75
Aug 13 2015 08:17
@Mistereo Thanks
One of the tests is
assert.deepEqual(sym([1, 2, 5], [2, 3, 5], [3, 4, 5]), [1, 4, 5]
shouldn't the 5 be excluded, so
assert.deepEqual(sym([1, 2, 5], [2, 3, 5], [3, 4, 5]), [1, 4]
or am I missing something?
Bianca Mihai
@biancamihai
Aug 13 2015 08:24
@jjmax75 sym(a,b,c) = sym(sym(a,b,c))
Mistereo
@Mistereo
Aug 13 2015 08:24
@jjmax75 yes, sym(a, b, c) = sym(sym(a, b), c)
Bianca Mihai
@biancamihai
Aug 13 2015 08:25
sym([1, 2, 5], [2, 3, 5], [3, 4, 5]) = sym(sym([1, 2, 5], [2, 3, 5]),[3, 4, 5])
Mistereo
@Mistereo
Aug 13 2015 08:25
@jjmax75 also symdiff is associative
= sym(a, sym(b, c))
Bianca Mihai
@biancamihai
Aug 13 2015 08:25
=> sym([1,3],[3,4,5]) => [1,4,5]
Shaklin
@ShaklinSyed
Aug 13 2015 08:27
Hi guys
John Behan
@jjmax75
Aug 13 2015 08:27
OK, so symmetric difference in math is just between two sets of values
If you want to get the symmetric difference of three sets, you do one set first, and then compare the result to the third set, is that right?
Shaklin
@ShaklinSyed
Aug 13 2015 08:28
Quick question : is anyone available who has completed functional programming waypoint
@jjmax75 yes
John Behan
@jjmax75
Aug 13 2015 08:28
Thanks @Mistereo @biancamihai @ShaklinSyed
CamperBot
@camperbot
Aug 13 2015 08:28
jjmax75 sends brownie points to @mistereo and @biancamihai and @shaklinsyed :sparkles: :thumbsup: :sparkles:
hey @jjmax75 if you found this info helpful :point_right: consider adding a wiki article!
John Behan
@jjmax75
Aug 13 2015 08:30
@ShaklinSyed I've finished it
Bianca Mihai
@biancamihai
Aug 13 2015 08:32
@jjmax75 consider adding a wiki article now ;)
John Behan
@jjmax75
Aug 13 2015 08:34
@biancamihai will do, i thought it was the intersection of all the sets of numbers, that's a few hours wasted :)
Shaklin
@ShaklinSyed
Aug 13 2015 08:35
@jjmax75 just wanted to know if we need to complete all 42 excercises
Bianca Mihai
@biancamihai
Aug 13 2015 08:35
yeah, that will help others a lot @jjmax75
John Behan
@jjmax75
Aug 13 2015 08:36
@biancamihai thanks
Ozy Design & Software
@OzySky
Aug 13 2015 08:55
This message was deleted
This message was deleted
This message was deleted
This message was deleted
Chirag Patel
@CPatel217
Aug 13 2015 09:08
can someone help with this code? im trying to learn OOP in javascript
function Employee() {
  this.name = "";
  this.dept = "general";
}

function Manager() {
  Employee.call(this);
  this.reports = [];
}
Manager.prototype = Object.create(Employee.prototype);
so i understand what the last line is doing. i think. this line allows Manager object to inherit from Employee object via use of prototypes
i believe
but what about Employee.call(this); //no clue what this is for
Mistereo
@Mistereo
Aug 13 2015 09:10
@CPatel217 this is the context, check .call documentation.
Chirag Patel
@CPatel217
Aug 13 2015 09:10
yeah i've tried so many times to understand taht particular doc
Mistereo
@Mistereo
Aug 13 2015 09:11
@CPatel217 ok, what is this in Employee constructor?
Chirag Patel
@CPatel217
Aug 13 2015 09:11
the environment of Employee
oh wait...mmm the Employee constructor object?
Mistereo
@Mistereo
Aug 13 2015 09:12
Check this:
var context = {};
Employee.call(context);
console.log(context);
Chirag Patel
@CPatel217
Aug 13 2015 09:14
k one sec
i get this Object {name: "", dept: "general"}
Mistereo
@Mistereo
Aug 13 2015 09:16
Can you explain why?
Chirag Patel
@CPatel217
Aug 13 2015 09:17
yea hmmm..hold on
ok so Employee has the properties name:... and dept:...
so the context is Object object with those properties
is that right
Chirag Patel
@CPatel217
Aug 13 2015 09:22
i mean so every object has to have its prototype from some object, in case of Employee its the Object object with name and dept properties
im not sure im explaining it clearly
im not sure i understand it clearly LOL
Chirag Patel
@CPatel217
Aug 13 2015 09:30
am around the mark?
Chirag Patel
@CPatel217
Aug 13 2015 09:40
If you could put it in your own words how would you say it
Paul
@pjim
Aug 13 2015 09:40
Does anyone know how to login to the mongodb in cloud9? I can get the db started per the instructions on get set for basejumps, but I don't know what to use as a connection string to connect with the database from within the app?
Chirag Patel
@CPatel217
Aug 13 2015 09:45
i've tried reading that call doc but just not getting it.
Chirag Patel
@CPatel217
Aug 13 2015 09:48
ok...i'll give it another shot
Paul
@pjim
Aug 13 2015 09:48
@CPatel217 if you need to understand call and bind this article should help http://javascriptissexy.com/javascript-apply-call-and-bind-methods-are-essential-for-javascript-professionals/
@CPatel217 though you should read this one first really http://javascriptissexy.com/understand-javascripts-this-with-clarity-and-master-it/
Chirag Patel
@CPatel217
Aug 13 2015 09:49
thats a good site @pjim thanks
Paul
@pjim
Aug 13 2015 09:49
np
Mistereo
@Mistereo
Aug 13 2015 09:49
@CPatel217 basically this is the link to the context. The .call method can replace context for us. So as in previous example:
var context = {};
Employee.call(context); // here we replace context of Employee to variable context.
// If you just call Employee like so:
Employee(); //this will link to global context (window in browsers) (if not in strict mode)
console.log(context);
so when you operate with this. e.g.: this.name = "Mike"; you actually operate with context object.
Ozy Design & Software
@OzySky
Aug 13 2015 09:51
This message was deleted
bonfire exact change
CamperBot
@camperbot
Aug 13 2015 09:52

:fire:Bonfire: Exact Change :link:

function drawer(price, cash, cid) {
  var change;
  // Here is your change, ma'am.
  return change;
}

// Example cash-in-drawer array:
// [['PENNY', 1.01],
// ['NICKEL', 2.05],
// ['DIME', 3.10],
// ['QUARTER', 4.25],
// ['ONE', 90.00],
// ['FIVE', 55.00],
// ['TEN', 20.00],
// ['TWENTY', 60.00],
// ['ONE HUNDRED', 100.00]]

drawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]);

Design a cash register drawer function that accepts purchase price as the first argument, payment as the second argument, and cash-in-drawer (cid) as the third argument.

more info:  bf details | bf links | hint

Ozy Design & Software
@OzySky
Aug 13 2015 09:52
bf details
CamperBot
@camperbot
Aug 13 2015 09:52

:fire:Bonfire: Exact Change :link:

function drawer(price, cash, cid) {
  var change;
  // Here is your change, ma'am.
  return change;
}

// Example cash-in-drawer array:
// [['PENNY', 1.01],
// ['NICKEL', 2.05],
// ['DIME', 3.10],
// ['QUARTER', 4.25],
// ['ONE', 90.00],
// ['FIVE', 55.00],
// ['TEN', 20.00],
// ['TWENTY', 60.00],
// ['ONE HUNDRED', 100.00]]

drawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]);
Design a cash register drawer function that accepts purchase price as the first argument, payment as the second argument, and cash-in-drawer (cid) as the third argument.
cid is a 2d array listing available currency.
Return the string "Insufficient Funds" if cash-in-drawer is less than the change due. Return the string "Closed" if cash-in-drawer is equal to the change due.
Otherwise, return change in coin and bills, sorted in highest to lowest order.
Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>RSAP</a> if you get stuck. Try to pair program. Write your own code.
links:
Ozy Design & Software
@OzySky
Aug 13 2015 09:52
This message was deleted
CamperBot
@camperbot
Aug 13 2015 09:52
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Richard Vankoningsveld
@richyvk
Aug 13 2015 09:53
Can someone help me with Factorialize a Number? I've seen it done with recurrsion, but that just makes my head explode!
Chirag Patel
@CPatel217
Aug 13 2015 09:53
ok thanks @Mistereo. much more clearer now
Richard Vankoningsveld
@richyvk
Aug 13 2015 09:54
Or alternatively how do I get help from Camperbot?
Bastien Lemaire
@blemaire
Aug 13 2015 09:56
Hi all
is there a way to register a filter in a directive only ?
zcrnivec
@zcrnivec
Aug 13 2015 10:02
Could anyone help with Bonfire: Make a Person please
CamperBot
@camperbot
Aug 13 2015 10:02
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
zcrnivec
@zcrnivec
Aug 13 2015 10:02
Bonfire: Make a Person please
CamperBot
@camperbot
Aug 13 2015 10:02
Sorry, can't find a bonfire called make a person please. [ Check the map? ]
Sergey Zhidkov
@sergey-zhidkov
Aug 13 2015 10:14
@zcrnivec this is really easy bonfire, but tests are not good
@zcrnivec what is the problem with person?
Richard Vankoningsveld
@richyvk
Aug 13 2015 10:26
bonfire Factorialize a Number
CamperBot
@camperbot
Aug 13 2015 10:26

:fire:Bonfire: Factorialize a Number :link:

function factorialize(num) {
  return num;
}

factorialize(5);

Return the factorial of the provided integer.

more info:  bf details | bf links | hint

Richard Vankoningsveld
@richyvk
Aug 13 2015 10:27
hint
CamperBot
@camperbot
Aug 13 2015 10:27
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
zcrnivec
@zcrnivec
Aug 13 2015 11:04
This message was deleted
Alex R
@queevenalak
Aug 13 2015 11:09
Hi guys
Mark Jackson
@markjjackson
Aug 13 2015 11:27
bonfire Chunky Monkey
CamperBot
@camperbot
Aug 13 2015 11:27

:fire:Bonfire: Chunky Monkey :link:

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

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

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

more info:  bf details | bf links | hint

Mark Jackson
@markjjackson
Aug 13 2015 11:27
hint
CamperBot
@camperbot
Aug 13 2015 11:27
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Hiroka
@hirokak
Aug 13 2015 12:12
Hi everyone! I don't know if I should stick with the topic about FCC....anyone here familiar with dreamweaver fluid grid??
Abhisek Pattnaik
@abhisekp
Aug 13 2015 12:50
@hirokak any links about it?
@hirokak btw, you should stick with FCC courseware
Anna Presnyakova
@chiffenok
Aug 13 2015 13:27
hi, guys. I kind of stuck with bonfire 13. I didn't get on what point we suppose to use hasOwnProperty?
can somebody give a hint ?
Coira Ellison
@Coira
Aug 13 2015 13:30
hi @chiffenok what's the name of the bonfire?
Anna Presnyakova
@chiffenok
Aug 13 2015 13:33
Where art thou , task suppose to be easy but nothing clever came to my mind @Coira
Coira Ellison
@Coira
Aug 13 2015 13:34
bonfire where are thou
CamperBot
@camperbot
Aug 13 2015 13:34
Sorry, can't find a bonfire called where are thou. [ Check the map? ]
Coira Ellison
@Coira
Aug 13 2015 13:34
bonfire Where Art Thou
CamperBot
@camperbot
Aug 13 2015 13:34

:fire:Bonfire: Where art thou :link:

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

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

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

more info:  bf details | bf links | hint

Coira Ellison
@Coira
Aug 13 2015 13:35
@chiffenok do you have any code for it done?
Rodrigo Fierro R.
@rodrigofierro
Aug 13 2015 13:35
@chiffenok use the splice(); method
Anna Presnyakova
@chiffenok
Aug 13 2015 13:36
not so much moment
This message was deleted
CamperBot
@camperbot
Aug 13 2015 13:36
:bulb: to format code use backticks! ``` more info
Anna Presnyakova
@chiffenok
Aug 13 2015 13:37
This message was deleted
CamperBot
@camperbot
Aug 13 2015 13:37
:bulb: to format code use backticks! ``` more info
Anna Presnyakova
@chiffenok
Aug 13 2015 13:37
'''
CamperBot
@camperbot
Aug 13 2015 13:37
:bulb: to format code use backticks! ``` more info
Abhisek Pattnaik
@abhisekp
Aug 13 2015 13:37
help code format
CamperBot
@camperbot
Aug 13 2015 13:37

: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

Rodrigo Fierro R.
@rodrigofierro
Aug 13 2015 13:37
code
Leandro Santos
@leaudro
Aug 13 2015 13:37
@chiffenok you have to look for objects that matches the attributes on source inside collection. To do that, you need to iterate on the collection and check if each one has the same keys as in source
Rodrigo Fierro R.
@rodrigofierro
Aug 13 2015 13:38
"" code ""
Anna Presnyakova
@chiffenok
Aug 13 2015 13:38
function where(collection, source) {
  var arr = [];
  // What's in a name?
  //console.log(Object.keys(source));
  var propSource = Object.keys(source);
  //console.log(collection[0].hasOwnProperty('last'));
  //console.log(collection[0]['first'])
  for (var i = 0; i < collection.length; i++) {      
      //console.log(collection[i]['first']);
      for (var j = 0; j < propSource.length; j++) {
          console.log(collection[i][propSource[j]] );
          console.log('---- ' + source[propSource[j]]);
      }
      //console.log(collection[i]['last']);
  }
  return arr;
}
Leandro Santos
@leaudro
Aug 13 2015 13:39
@chiffenok you are halfway through
Anna Presnyakova
@chiffenok
Aug 13 2015 13:40
@leaudro what's next how to check that?
Moisés Man
@moigithub
Aug 13 2015 13:40
bf details
CamperBot
@camperbot
Aug 13 2015 13:40

:fire:Bonfire: Where art thou :link:

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

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
Make a function that looks through a list (first argument) and returns an array of all objects that have equivalent property values (second argument).
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.
links:
Leandro Santos
@leaudro
Aug 13 2015 13:41
now you have to check if collection[i].hasOwnProperty(propSource[j]) for each propSource... If collection[i] has them all, then you push it to arr
Abhisek Pattnaik
@abhisekp
Aug 13 2015 13:41
@chiffenok use Array.filter that you learnt in your previous lessons
Leandro Santos
@leaudro
Aug 13 2015 13:42
that's an option too
Anna Presnyakova
@chiffenok
Aug 13 2015 13:42
ok, but I need to check value too
Abhisek Pattnaik
@abhisekp
Aug 13 2015 13:43
@chiffenok first write the Array.filter and post your code
Coira Ellison
@Coira
Aug 13 2015 13:44
you don't need to use filter though, a for loop works fine
whatever's easier
Abhisek Pattnaik
@abhisekp
Aug 13 2015 13:45
@Coira I think while learning JS, we must learn about higher order functions. With that comes the real beauty of JS.
Also we must re-use things we learn in previous lessons.
@Coira And if one has completed the previous lesson using Array.filter, that means they're aware of it's use and it becomes one step easier to use than before. :)
Coira Ellison
@Coira
Aug 13 2015 13:47
@abhisekp true, but I think it depends on where you are in your learning. you can always translate it to filter later, and because you've seen it as a plain loop it can make more sense
Leandro Santos
@leaudro
Aug 13 2015 13:47
@chiffenok to check the value, I used some auxiliar variables, so it's easier to do and read. like:
var obj = collection[i];
var key = propSource[j];

if (obj[key] === source[key]) {
}
Abhisek Pattnaik
@abhisekp
Aug 13 2015 13:47
@chiffenok btw, you can write the full code at http://coderpad.io and test it there. If it works, copy it to FCC and run code.
Anna Presnyakova
@chiffenok
Aug 13 2015 13:48
@leaudro thanks i'll try
@abhisekp why do I need to use additional resources? I use old sublime text and chrome for that. I never print directly in fcc
hint
CamperBot
@camperbot
Aug 13 2015 13:52
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Abhisek Pattnaik
@abhisekp
Aug 13 2015 13:52
@chiffenok oh! Yeah! You can do that too. :D
But do try your hands on coderpad.io You might like it.
Mehrosh
@mehroshh
Aug 13 2015 13:54
hello guys!
Abhisek Pattnaik
@abhisekp
Aug 13 2015 13:56
@mehroshh hey! hi
@mehroshh did you know? We're neighbour. :P
Anna Presnyakova
@chiffenok
Aug 13 2015 13:58
@abhisekp nope, I even kind against it, I think we need to learn how to debug code in chrome, not using a lot of additional tools and resources
Abhisek Pattnaik
@abhisekp
Aug 13 2015 13:59
@chiffenok whatever you wish :D
Mehrosh
@mehroshh
Aug 13 2015 13:59
yeah I figured that out the other day from your pfile @abhisekp good to see you, mate xD
Abhisek Pattnaik
@abhisekp
Aug 13 2015 14:01
@mehroshh meh! roshhh...
:smile:
Mehrosh
@mehroshh
Aug 13 2015 14:04
It's Mehrosh actually but since that was taken I had to stick an extra H xD @abhisekp
Abhisek Pattnaik
@abhisekp
Aug 13 2015 14:04
@mehroshh nice name though. :+1:
Mehrosh
@mehroshh
Aug 13 2015 14:05
thanks, i guesx
brb
Leandro Santos
@leaudro
Aug 13 2015 14:07
@chiffenok so, have you finished that bonfire?
Carlos
@krlooss
Aug 13 2015 14:16
hi, anyone available for pair programming? PM me
Matthew Barber
@Honno
Aug 13 2015 14:19
bonfire where are thou
CamperBot
@camperbot
Aug 13 2015 14:19
Sorry, can't find a bonfire called where are thou. [ Check the map? ]
Matthew Barber
@Honno
Aug 13 2015 14:19
bonfire where art
CamperBot
@camperbot
Aug 13 2015 14:19

:fire:Bonfire: Where art thou :link:

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

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

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

more info:  bf details | bf links | hint

Lightwaves
@Lightwaves
Aug 13 2015 14:20
You know what the bot needs
levenshtein distance algorithm to handy fuzzy strings
that way if someone just writes where it doesn't reply with nothing found but instead replies with did you mean this...
if it's sufficiently close
Roy
@CruelCoin
Aug 13 2015 14:21
@Lightwaves True. Mind you, this is the very first implementation of the bot, so will probably see a load of patches in the next few months
Sean-Michael Jonesz
@SMJonesz
Aug 13 2015 14:24
Bonfire: Check for Palindromes
CamperBot
@camperbot
Aug 13 2015 14:24

:fire:Bonfire: Check for Palindromes :link:

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



palindrome("eye");

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

more info:  bf details | bf links | hint

Ozy Design & Software
@OzySky
Aug 13 2015 14:24
@Lightwaves maybe the bot requests and responses should be only shown to the person who requested it?
it does clog the chat a bit
Roy
@CruelCoin
Aug 13 2015 14:28
@ozydesign Nah. If people ask for help, its handy for them to call up the synopsis.
Before this, there was way too much "Can you post what you are trying to do?"
Ammar Ali Shah
@AmmarAliShah
Aug 13 2015 15:00
Need some bonfire help
Aleksandar B.
@aleksandar-b
Aug 13 2015 15:02
What || means in this context?
out = out || {};
Coira Ellison
@Coira
Aug 13 2015 15:02
hi @AmmarAliShah what do you need help with?
@samosale it's 'or', so something like, if var out exists, assign it to out, otherwise assign {} to out
I'm not sure if that's very clear, I'll find a better explanation
Aleksandar B.
@aleksandar-b
Aug 13 2015 15:07
yes it is clear.. What if both exists?
@Coira
Coira Ellison
@Coira
Aug 13 2015 15:08
it takes the first value it comes across, so in this case 'out'
Aleksandar B.
@aleksandar-b
Aug 13 2015 15:08
tnx
Matthew Barber
@Honno
Aug 13 2015 15:08
Guys my bonfire no repeats soltuion is too big, http://pastebin.com/Mth4HW3R#
It won't test properly on FCC or another quick compile site :/
May I see someone elses?
Coira Ellison
@Coira
Aug 13 2015 15:09
@samosale np, called short-circuit evaluation (according to stackoverflow) if you want to look it up
Aleksandar B.
@aleksandar-b
Aug 13 2015 15:14
@Coira I will , thanks.:)
Coira Ellison
@Coira
Aug 13 2015 15:18
:)
hi @Honno just looking at your code, trying to work out where the infinite loop is
Matthew Barber
@Honno
Aug 13 2015 15:19
@Coira Yeah I'm tired, this worked for the small examples I did but when it gets overly big I don't know if it's just ineffecient or theres an infinite loop
I just cba anymore :p
Coira Ellison
@Coira
Aug 13 2015 15:20
ha, after a while your brain just goes numb!
I'll have a go at working it out, but perhaps someone more experienced than me will get to it first
Aleksandar B.
@aleksandar-b
Aug 13 2015 15:22
bf Exact Change
CamperBot
@camperbot
Aug 13 2015 15:22

:fire:Bonfire: Exact Change :link:

function drawer(price, cash, cid) {
  var change;
  // Here is your change, ma'am.
  return change;
}

// Example cash-in-drawer array:
// [['PENNY', 1.01],
// ['NICKEL', 2.05],
// ['DIME', 3.10],
// ['QUARTER', 4.25],
// ['ONE', 90.00],
// ['FIVE', 55.00],
// ['TEN', 20.00],
// ['TWENTY', 60.00],
// ['ONE HUNDRED', 100.00]]

drawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]);

Design a cash register drawer function that accepts purchase price as the first argument, payment as the second argument, and cash-in-drawer (cid) as the third argument.

more info:  bf details | bf links | hint

Aleksandar B.
@aleksandar-b
Aug 13 2015 15:22
hint
CamperBot
@camperbot
Aug 13 2015 15:22
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Aleksandar B.
@aleksandar-b
Aug 13 2015 15:22
bf links
CamperBot
@camperbot
Aug 13 2015 15:22
links:
Carlos
@krlooss
Aug 13 2015 15:23

hello, what does this error means? it has a weird grammar I feel -Yoda

assert.deepEqual(palindrome("not a palindrome"), false);expected true to deeply equal false

Ammar Ali Shah
@AmmarAliShah
Aug 13 2015 15:23
@Coira Palindrome bonfire
Carlos
@krlooss
Aug 13 2015 15:27
yes, that one, but, why is it expected true?
if not a palindrome is not a palindrome
Coira Ellison
@Coira
Aug 13 2015 15:30
@Honno recursion is one of those things I have real trouble with, I used a stack-based solution if you want to see?
@krlooss ignore the deepEqual stuff, what it's saying is, it called palindrome("not a palindrome"), and received the answer 'true', when it really wanted 'false'
@AmmarAliShah what have you managed to do so far?
Rex Schrader
@SaintPeter
Aug 13 2015 15:37
@krlooss Your code returned true, it expected it to be false.
Matthew Barber
@Honno
Aug 13 2015 15:40
@Coira yes please
Anna Presnyakova
@chiffenok
Aug 13 2015 15:45
Guy, I completely can't understand bonfire Where art thou
Can somebody give me a hint ?
````
Matthew Barber
@Honno
Aug 13 2015 15:46
bonfire where art
CamperBot
@camperbot
Aug 13 2015 15:46

:fire:Bonfire: Where art thou :link:

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

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

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

more info:  bf details | bf links | hint

Nic Galluzzo
@ngalluzzo
Aug 13 2015 15:46
anyone here wanna share their answer for inventory update?
just curious to see how others solved it
Matthew Barber
@Honno
Aug 13 2015 15:46
@chiffenok You need to return either true or false if all the items in the array contain the property name "last" and value "capulet"
Anna Presnyakova
@chiffenok
Aug 13 2015 15:47
function where(collection, source) {
  var arr = [];
  // What's in a name?
  var propSource = Object.keys(source);
  for (var i = 0; i < collection.length; i++) {
      for (var j = 0; j < propSource.length; j++) {
          if (collection[i].hasOwnProperty(propSource[j])) {
              var obj = collection[i];
              var key = propSource[j];
              if (obj[key] === source[key]) {
                  arr.push(obj);
                  console.log(arr);
            }
          }
      }
  }
  return arr;
}
Feners4
@Feners4
Aug 13 2015 15:49
can i get some help with getting my searchTxt input to work http://codepen.io/Feners4/pen/ZGZORX
i cant get it to store any user input and use to query wiki api...
Abhisek Pattnaik
@abhisekp
Aug 13 2015 15:54
@chiffenok you're still stuck in it?
Anna Presnyakova
@chiffenok
Aug 13 2015 15:56
@abhisekp I was busy with diffrent stuff , but when I come back to bonfire yes
Coira Ellison
@Coira
Aug 13 2015 15:58
@chiffenok you don't need the second for loop, source only has 1 item in it
so use something like
var propSource = Object.keys(source)[0];
unless you're meant to check source for multiple values and I didn't?
Carlos
@krlooss
Aug 13 2015 16:01
thank you. I know FCC sometimes intends to be funny, but it should not be in that confusing yoda way funny
Mehrosh
@mehroshh
Aug 13 2015 16:02
lol @krlooss
Joanna Georgescu
@joannatg
Aug 13 2015 16:02
Hi, could someone help me understand why Number.isNaN(37) is false? Doing last bonfire (Arguments_Optional) and I wanted to use Number.isNaN to id valid numbers, but it`s not working...
Mehrosh
@mehroshh
Aug 13 2015 16:04
@joannatg isNan() bascially returns true if the value is NaN and returns false if value is not Nan
Coira Ellison
@Coira
Aug 13 2015 16:04
is 37 "not a number", but 37 is a number, so isNaN(37) is false
David Vaughan-Brown
@dvaun
Aug 13 2015 16:04
^ @mehroshh would isNaN(!37) then work?
Nic Galluzzo
@ngalluzzo
Aug 13 2015 16:04
needs to be !isNaN(37)
Mehrosh
@mehroshh
Aug 13 2015 16:05
@dvaun what @ngalluzzo said xD
David Vaughan-Brown
@dvaun
Aug 13 2015 16:05
thanks @mehroshh @ngalluzzo
CamperBot
@camperbot
Aug 13 2015 16:05
dvaun sends brownie points to @mehroshh and @ngalluzzo :sparkles: :thumbsup: :sparkles:
hey @dvaun if you found this info helpful :point_right: consider adding a wiki article!
:star: 96 | @ngalluzzo | http://www.freecodecamp.com/ngalluzzo
Mehrosh
@mehroshh
Aug 13 2015 16:05
fire up your browser console and do all kind of freaky tests like this
Joanna Georgescu
@joannatg
Aug 13 2015 16:05
@mehroshh thanks!
Omar
@oab00
Aug 13 2015 16:05
@Feners4 do you want to call the wiki service every time u type something in the input ?
David Vaughan-Brown
@dvaun
Aug 13 2015 16:06
i actually came in here to ask a different question. is there some place down the line where there is a difference between using dot or bracket notation when calling object information?
Joanna Georgescu
@joannatg
Aug 13 2015 16:06
woot! woot! !Number.isNaN(37) gets me true! thanks!
Mehrosh
@mehroshh
Aug 13 2015 16:06
asdf.PNG
using browser console really helps determine falsey and truhty xD
Rob
@BobsHub
Aug 13 2015 16:07
if you pass "37" as a string argument, isNaN("37") would also return false, try using typof to test
Nic Galluzzo
@ngalluzzo
Aug 13 2015 16:07
yeah @mehroshh that’s why I was just saying… FCC totally needs ‘Dev Console’ lesson
Omar
@oab00
Aug 13 2015 16:07
yeah typeof is much more predictable
Mehrosh
@mehroshh
Aug 13 2015 16:08
agreed @ngalluzzo
Omar
@oab00
Aug 13 2015 16:08
typeof '37' === 'number' => false
Nic Galluzzo
@ngalluzzo
Aug 13 2015 16:08
maybe I’ll write up a wiki with some tips
Mehrosh
@mehroshh
Aug 13 2015 16:09
if you need to find falsey and truthy then browser console is the best way to do it
however, if you are confuse as to what's the type of something, then you can proceed to typeof(whatever) thing
Joanna Georgescu
@joannatg
Aug 13 2015 16:10
@BobsHub @oab00 got it, typeof it is then, thanks!
Omar
@oab00
Aug 13 2015 16:11

FCC totally needs ‘Dev Console’ lesson

it did have one before didn't it? but was a little too buggy
I think this was it https://www.codeschool.com/courses/discover-devtools

Mehrosh
@mehroshh
Aug 13 2015 16:12
my fav wiki so far is this
help rtfm
CamperBot
@camperbot
Aug 13 2015 16:12

:point_right: rtfm [wiki]

RTFM is an initialism for the expression "Read The F**king Manual"

RTFM Comic

:pencil: read more about rtfm on the FCC Wiki

Mehrosh
@mehroshh
Aug 13 2015 16:12
xD
Rob
@BobsHub
Aug 13 2015 16:13
not a bad idea to use isNaN too though, among other tests lke if it is an integer if(Math.floor(x) === x)
Carlos
@krlooss
Aug 13 2015 16:19
i think there is a isInteger() function too
Mark Dang
@dangm24
Aug 13 2015 16:19
Hey all, I could use some help to finish up Bonfire: Make a Person
CamperBot
@camperbot
Aug 13 2015 16:19
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Feners4
@Feners4
Aug 13 2015 16:21
@oab00 yup
@oab00 so the user input is inserted in the link call I'm doing, getting that result...
Omar
@oab00
Aug 13 2015 16:23
so you need a function to be called every time there's an input
say you make a function called inputChanged()
then you would add the ng-change='inputChanged()' to the input in html
and define the function in the controller $scope.inputChanged = function () { ... }
CamperBot
@camperbot
Aug 13 2015 16:24
:trollface: troll problems? notify admins here
Abhisek Pattnaik
@abhisekp
Aug 13 2015 16:24
@camperbot is a troll :trollface:
CamperBot
@camperbot
Aug 13 2015 16:24
:trollface: troll problems? notify admins here
Omar
@oab00
Aug 13 2015 16:25
bot pls :disappointed:
CamperBot
@camperbot
Aug 13 2015 16:25
no wiki entry for: pls disappointed
:pencil: click here to create one now!after creating your page type update to reload it here
Rob
@BobsHub
Aug 13 2015 16:25
yes thats new with ecmascript 6
lot's of new stuff
Luis Felipe López G.
@luishendrix92
Aug 13 2015 16:29
wiki arrow functions
CamperBot
@camperbot
Aug 13 2015 16:29
no wiki entry for: arrow functions
:pencil: click here to create one now!after creating your page type update to reload it here
Carla Berjano
@CarlaBpt
Aug 13 2015 16:34
Hi, I need help for #13, anyone please? :)
Luis Felipe López G.
@luishendrix92
Aug 13 2015 16:35
@CarlaBpt Waypoint 13, Bonfire 13 or what's that
bf slasher flick
CamperBot
@camperbot
Aug 13 2015 16:35

:fire:Bonfire: Slasher Flick :link:

function slasher(arr, howMany) {
  // it doesn't always pay to be first
  return arr;
}

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

Return the remaining elements of an array after chopping off n elements from the head.

more info:  bf details | bf links | hint

Luis Felipe López G.
@luishendrix92
Aug 13 2015 16:35
bf details
CamperBot
@camperbot
Aug 13 2015 16:35

:fire:Bonfire: Slasher Flick :link:

function slasher(arr, howMany) {
  // it doesn't always pay to be first
  return arr;
}

slasher([1, 2, 3], 2);
Return the remaining elements of an array after chopping off n elements from the head.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.
links:
Abhisek Pattnaik
@abhisekp
Aug 13 2015 16:36
@CarlaBpt write the full url to the FCC issue page
Carla Berjano
@CarlaBpt
Aug 13 2015 16:36
@luishendrix92 I've wrapped the buttons on divs but it's not recognizing
Jessi L Wasell
@JessiW
Aug 13 2015 16:37
bonfire pairwise
CamperBot
@camperbot
Aug 13 2015 16:37

:fire:Bonfire: Pairwise :link:

function pairwise(arr, arg) {
  return arg;
}

pairwise([1,4,2,3,0,5], 7);

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.

more info:  bf details | bf links | hint

Jessi L Wasell
@JessiW
Aug 13 2015 16:37
hint
CamperBot
@camperbot
Aug 13 2015 16:37
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Carla Berjano
@CarlaBpt
Aug 13 2015 16:39
Oka, thanks :)
Carlos
@krlooss
Aug 13 2015 16:41
this camperbot is really fucking around, isn't it?
Cody Bouscaren
@codybousc
Aug 13 2015 16:43
does anyone know if there's a way to access our submitted bonfire answers?
Abhisek Pattnaik
@abhisekp
Aug 13 2015 16:43
@codybousc http://freecodecamp.com/codybousc (Your Profile Page) and this :point_down: August 13, 2015 10:13 PM
Luis Felipe López G.
@luishendrix92
Aug 13 2015 16:43
@codybousc Your own profile in FCC, just click on your avatar.
Cody Bouscaren
@codybousc
Aug 13 2015 16:44
awesome. thanks guys!
Clayton
@cjg040103
Aug 13 2015 16:52
hey guys! anybody know what's wrong w/ my code?
var friends = {
    bill: {
        firstName: '',
        lastName: '',
        number: '',
        address: ['']
    },
    steve: {
        firstName: '',
        lastName: '',
        number: '',
        address: ['']
    }
}
function list() {
    for (var key in friends) {
        console.log(friends[key]);
        return friends[key];
    };
}
Veronika Benkeser
@veronikabenkeser
Aug 13 2015 16:59
@cjg040103 you're only returning bill because you have the return statement inside of the for loop
Omar
@oab00
Aug 13 2015 17:00
didn't u solve this yesterday :worried:
Clayton
@cjg040103
Aug 13 2015 17:00
yup...
:worried:
Omar
@oab00
Aug 13 2015 17:00
what happened?
Clayton
@cjg040103
Aug 13 2015 17:00
its just a very annoying problem.
Omar
@oab00
Aug 13 2015 17:01
you're missing an argument I think
Dayne Wright
@daynewright
Aug 13 2015 17:01
@cjg040103 Yes..the return will always end the loop. Plus you are logging out friends[key] when it just wants key.
Clayton
@cjg040103
Aug 13 2015 17:02
its not even the one i'm supposed 2 b doing. i'm just reviewing the javascript lessons 4 a bonfire problem that i'm stuck on
k
@Daynewr
Omar
@oab00
Aug 13 2015 17:03
why is all friend details empty ?
Clayton
@cjg040103
Aug 13 2015 17:03
i feels stoopid.
all i had 2 do was delete the return and replace the 'friends[key]' with 'key'
Alex
@k1lly
Aug 13 2015 17:06
Hey guy
s
can you give me a hint? I don't get the task at all
Bonfire: Map the Debris
CamperBot
@camperbot
Aug 13 2015 17:06

: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

Alex
@k1lly
Aug 13 2015 17:06

Here's what I got:
`function orbitalPeriod(arr) {
var GM = 398600.4418;
var earthRadius = 6367.4447;
return 2 Math.PI Math.pow((arr.avgAlt^3, 1/2)/GM);
}

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

Dayne Wright
@daynewright
Aug 13 2015 17:07

@k1lly Here is a hint that was given to me that may help:

T = 2pi radical a^3/GM
a = earthRadius + altitude

Alex
@k1lly
Aug 13 2015 17:07
ty @Daynewr
Luis Felipe López G.
@luishendrix92
Aug 13 2015 17:10
wiki map the debris
Alex
@k1lly
Aug 13 2015 17:13
@luishendrix92 wow nice bot
@luishendrix92 thanks, it helped a lot! I forgot to round the numbers
Luis Felipe López G.
@luishendrix92
Aug 13 2015 17:15
YW, floating points in JS are... broken because of the standard for numbers they chose.
Alex
@k1lly
Aug 13 2015 17:16
yeah I remember the joke "Robocaptcha: prove that you're a human: 0.2 + 0.3. ROBOT: 0.50000000000000000000001"
Brett Guillory
@kurzninja
Aug 13 2015 17:19
LOLOL
Caroline Dikibo
@cdikibo
Aug 13 2015 17:22
so I need help with bonfire spinal tap case
function spinalCase(str) {
// "It's such a fine line between stupid, and clever."
// --David St. Hubbins


for(i=0; i<str.length; i++){
  if(str[i]===" "){
    return(str.replace(/ /g, "-").toLowerCase());
}
  if(str[i]==="_"){
    return(str.replace(/_/g, "-").toLowerCase());
} 
  if(str[i]===""){
    return(str.replace(/\B([A-Z])([a-z])/g, "-$1").toLowerCase());
}
}
}
spinalCase('This Is Spinal Tap');
CamperBot
@camperbot
Aug 13 2015 17:22
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Moisés Man
@moigithub
Aug 13 2015 17:27
if u use replace + regex with the "g"lobal flag it will replace all matches
"hello world".replace(/l/g, "R") <--- will return "heRRo worRd"
so no need to iterate
@cdikibo
u can open devtools console to test "hello world".replace(/l/g, "R")
also RETURN exit the function...
Cody Bouscaren
@codybousc
Aug 13 2015 17:31
hey all, i'm a bit stuck on Bonfire #20. So far, I'm able to return an array with the 'unique' element if there's only one unique element in both arrays. I'm not sure how to make this work with two unique elements though. Any advice?
function diff(arr1, arr2) {
  var newArr = [];
    //sorts the arrays 
    var sortedArr1 = arr1.sort(function(a, b){return a-b});
    var sortedArr2 = arr2.sort(function(a, b){return a-b});

    //Finds array longest in length 
      var longest; 
      var shortest;
      if(arr1.length > arr2.length) {
          longest = sortedArr1;
          shortest = sortedArr2;
      }
      else {
           longest = sortedArr2;
           shortest = sortedArr1;
      }

     for (var i = 0; i < longest.length; i++) {
         console.log("Longest: " + longest[i]);
         console.log("Shortest: " + shortest[i]);
            if (longest[i] !== shortest[i]) {
                newArr.push(longest[i])
                break;
            }

     } //outer for loop closing tag     
    return newArr; 
}

console.log(diff(['andesite', 'grass', 'dirt', 'pink wool', 'dead shrub'], ['diorite', 'andesite', 'grass', 'dirt', 'dead shrub']));
Brett Guillory
@kurzninja
Aug 13 2015 17:32
yay Minecraft!
Cody Bouscaren
@codybousc
Aug 13 2015 17:33
there's also a problem with my
newArr.push(longest[i])
line since i have no clue which array will have the unique element!
gravesr1993
@gravesr1993
Aug 13 2015 17:37
coming back after a hiatus, anyone mind helping me with the bonfire arguments optional? I don't understand what it exactly wants with the following:
If only one argument is provided, return a function that expects one additional argument and will return the sum. For example, add(2, 3) should return 5, and add(2) should return a function that is waiting for an argument so that var sum2And = add(2); return sum2And(3); // 5
CamperBot
@camperbot
Aug 13 2015 17:37
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
gravesr1993
@gravesr1993
Aug 13 2015 17:38
arguments optional
Omar
@oab00
Aug 13 2015 17:40
function argumentsOptional() {
    var returnedFunction = function(args) {
        ...
    };

    return returnedFunction;
}
artcode
@artecode
Aug 13 2015 17:52
The "line break" element <br>, is just for add space, not to add lines?
gravesr1993
@gravesr1993
Aug 13 2015 17:52
is this somewhat on the right path? seems to have a bug in it
function add() {
  if(arguments.length===1&&typeof arguments[0]==='number'){
    var someFunc= function(args){
      return arguments[0]+args;
    };
  return someFunc;
  }
  if(typeof arguments[0]==='number'&&typeof arguments[1] ==='number'){
    return arguments[0]+arguments[1];
  }
  return undefined;
}
Brett Guillory
@kurzninja
Aug 13 2015 17:54
@gravesr1993 I think your first if statement is returning the wrong thing
oh
nvm
it looks right
gravesr1993
@gravesr1993
Aug 13 2015 17:56
I changed it to <2 instead of ===1 and it returns the correct numbers in console, but it says xpect(add(2)(3)).to.equal(5);add(...) is not a function
Brett Guillory
@kurzninja
Aug 13 2015 17:58
does 'number' need to be capitalized?
Brett Guillory
@kurzninja
Aug 13 2015 17:59
yeah i'm looking at it on devdocs.io
you're right
Omar
@oab00
Aug 13 2015 17:59
so arguments[0] in someFunc isn't doing what you're expecting
args === arguments[0] in its case since that's the argument the function is seeing
so what add(2)(3) is doing is 3 + 3
Brett Guillory
@kurzninja
Aug 13 2015 18:00
I think he's right
"arguments" lists the arguments of the function it's inside
so inside the someFunc, arguments[0] is the arguments object of someFunc, not add()
gravesr1993
@gravesr1993
Aug 13 2015 18:01

okay so


    var argsLocal=arguments[0];
    return function(args){return argsLocal+args;};

instead?

Brett Guillory
@kurzninja
Aug 13 2015 18:01
there ya go
Omar
@oab00
Aug 13 2015 18:01
that should work ^^
Brett Guillory
@kurzninja
Aug 13 2015 18:01
try that
gravesr1993
@gravesr1993
Aug 13 2015 18:04
yeah, all but the last condition is working now, and not sure why that one isn't working because it's returning correctly in console as well haha
Omar
@oab00
Aug 13 2015 18:05
what ur code look like now
maybe u could use the add function to actually add instead of argsLocal+args
Omar
@oab00
Aug 13 2015 18:08
why do 1 + 1 when u can do add(1, 1) ^^
gravesr1993
@gravesr1993
Aug 13 2015 18:11
not sure I understand what you mean by add(1,1)? like a recursive? I tend to not use recursives and avoid them because they can cause confusion
Nic Galluzzo
@ngalluzzo
Aug 13 2015 18:11
oof, don’t do that
you’re gonna wanna kill yourself in the later bonfires hah
Omar
@oab00
Aug 13 2015 18:12
well the add() function already checks if arguments are numbers or not
so why not use it instead of checking again in the inside function :)
gravesr1993
@gravesr1993
Aug 13 2015 18:15
i'm not sure I follow still, is add() like already included in JS lib and this is just an overload or something?
gravesr1993
@gravesr1993
Aug 13 2015 18:26
but uhh, any clues on why it fails the last condition? it seems to return undefined in the grey box, and when I was logging it
Samuel Hunter
@MathManiac0
Aug 13 2015 18:29
Hey guys, can you help me with some JS I'm struggling with?
Benjamin
@b1ggb3n86
Aug 13 2015 18:30
@MathManiac0 We can try. What's up?
Samuel Hunter
@MathManiac0
Aug 13 2015 18:31
Are you familiar with the localStorage object?
Benjamin
@b1ggb3n86
Aug 13 2015 18:32
I'm not lol. Sorry. But I'm sure someone on here is.
rbunz
@rbunz08
Aug 13 2015 18:36
Can someone help me with my code...It is giving out exactly what I want until the last bit of code...
Samuel Hunter
@MathManiac0
Aug 13 2015 18:36
Sure... What programming language is it?
George
@sushiyea
Aug 13 2015 18:36

I need help with

#16. Waypoint: Line up Form Elements Responsively with Bootstrap

Donavin Northrup
@dnorthrupva
Aug 13 2015 18:36
@sushiyea What's up?
rbunz
@rbunz08
Aug 13 2015 18:36

Javascript.... The project asks....Perform a search and replace on the sentence using the arguments provided and return the new sentence.

First argument is the sentence to perform the search and replace on.

Second argument is the word that you will be replacing (before).

Third argument is what you will be replacing the second argument with (after).

Donavin Northrup
@dnorthrupva
Aug 13 2015 18:36
I know there is a command to tell me the requirements of it, but I forget.
!waypoint line up form elements
Nope, that ain't it. RIP
George
@sushiyea
Aug 13 2015 18:37
I can't figure out where I messed up on closing the my tags
<div class='row'>
<div class='col-xs-7'>
<input type='text' class='form-control' placeholder='cat photo URL' required>
</div>
<div class='col-xs-5'>
<button type='submit' class='btn btn-primary'><i class='fa fa-paper-plane'></i> Submit</button>
</div>
</form>
Donavin Northrup
@dnorthrupva
Aug 13 2015 18:37
You have 3 divs, and only 2 </div>
rbunz
@rbunz08
Aug 13 2015 18:37
@MathManiac0 This is what I have so far....
function replace(str, before, after) {

// creat an empty array
 var array = [];

// separate the array into its different arguments
 sentence = str.split(" ");
 console.log("sentence " + sentence); 

// search for the second argument in the first argument
   indexBefore = sentence.indexOf(before);
   console.log("indexBefore " + indexBefore);

// splice the third argument in its place
   finalSentence = sentence.splice(indexBefore, 1, after);
   console.log(finalSentence);

//push the final sentence into the empty array  
  array.push(finalSentence);

 return array;
}

replace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
Samuel Hunter
@MathManiac0
Aug 13 2015 18:37
@sushiyea Add three ` above and below the code
Donavin Northrup
@dnorthrupva
Aug 13 2015 18:37
The initial <div class='row'> is unclosed.
reismichel
@reismichel
Aug 13 2015 18:37
does anyone can help me with the palindrome challenge?
George
@sushiyea
Aug 13 2015 18:38
    <div class='row'>
    <div class='col-xs-7'>
  <input type='text' class='form-control' placeholder='cat photo URL' required>
    </div>
   <div class='col-xs-5'> 
  <button type='submit' class='btn btn-primary'><i class='fa fa-paper-plane'></i> Submit</button>
    </div>
     </form>
Donavin Northrup
@dnorthrupva
Aug 13 2015 18:38
So add another </div> under the last </div>
Samuel Hunter
@MathManiac0
Aug 13 2015 18:38
@rbunz08 Where is indexBefore defined?
George
@sushiyea
Aug 13 2015 18:39
Thanks sometimes the easiest things are over looked
rbunz
@rbunz08
Aug 13 2015 18:39
@MathManiac0 under my third //
Donavin Northrup
@dnorthrupva
Aug 13 2015 18:40
@sushiyea With tags, I like to extra indent. So anything within that FIRS <div> I indent again. This is a personal perference. Then of course just count "I have 1... 2... 3 <div> but only 2 </div>"
Samuel Hunter
@MathManiac0
Aug 13 2015 18:40
@rbunz08 Why are you putting the sentence array in an array?
rbunz
@rbunz08
Aug 13 2015 18:41
@MathManiac just so i could add the console.log(finalSentence)
@MathManiac0 nvm I guess I dont really need it..I took it out and it is still just giving me ["jumped"] or []
Jonathan Lee
@Jwing28
Aug 13 2015 18:43
hi, anyone comfortable with using .reduce()? not working on a project just have a question
Benjamin
@b1ggb3n86
Aug 13 2015 18:43
@Jwing28 Are you on bf Sum All Numbers???
rbunz
@rbunz08
Aug 13 2015 18:43
This message was deleted
@MathManiac0 I just cant get the splice to work as it should..
Samuel Hunter
@MathManiac0
Aug 13 2015 18:45
@rbunz08 So I looked at the docs and it returns the removed object. The .splice() should be treated as a command.
rbunz
@rbunz08
Aug 13 2015 18:45
how do I change it? @MathManiac0
Jonathan Lee
@Jwing28
Aug 13 2015 18:45
@b1ggb3n86 I already did that one but if you have a question or are curious how someone else did it i'm happy to talk about it
i just have a question about a specific thing when using .reduce()
Samuel Hunter
@MathManiac0
Aug 13 2015 18:46
sentence.splice(indexBefore, 1, after);
finalSentence = sentence;
I'm going out on a limb here, but try that.
Benjamin
@b1ggb3n86
Aug 13 2015 18:46
@Jwing28 yes, I didn't use .reduce() as I was not sure how to.
i used a for loop
Jonathan Lee
@Jwing28
Aug 13 2015 18:46
ah lemme take a look
rbunz
@rbunz08
Aug 13 2015 18:47
@MathManiac0 almost there.. I think I just have to join it back up!! That seems like such a finicky thing....
Benjamin
@b1ggb3n86
Aug 13 2015 18:47
This message was deleted
CamperBot
@camperbot
Aug 13 2015 18:47
:bulb: to format code use backticks! ``` more info
Donavin Northrup
@dnorthrupva
Aug 13 2015 18:47
The symbol is the grave.hilde key @b1ggb3n86 To the left of your '1'.
Benjamin
@b1ggb3n86
Aug 13 2015 18:48
@dnorthrupva thanks lol. i wasn't sure which one
function sumAll(arr) {
  var maxNum = Math.max.apply(null, arr);
  var minNum = Math.min.apply(null, arr);
  var total = 0;

  for(i = minNum; i <= maxNum; i++) {
    total += i;
  }
  return(total);
}

sumAll([1, 4]);
that's how i beat it. but i would like to use reduce() to learn how.
When in doubt. I tend to loop.
Jonathan Lee
@Jwing28
Aug 13 2015 18:49
@b1ggb3n86 well .reduce() iterates over each index in your array and since we only have [1,4] the result is going to be 5
Benjamin
@b1ggb3n86
Aug 13 2015 18:49
right. that's where i was stuck.
rbunz
@rbunz08
Aug 13 2015 18:49
@MathManiac0 Ive got a new issue now lol.. It is working but I need it to also keep the same format.. so if the word I removed had a capital letter, the word I replace it with also has to have the capital
Jonathan Lee
@Jwing28
Aug 13 2015 18:50
yeah
Samuel Hunter
@MathManiac0
Aug 13 2015 18:50
@rbunz08 Ahh, I hear regexes!
rbunz
@rbunz08
Aug 13 2015 18:50
@MathManiac0
function replace(str, before, after) {

// separate the array into its different arguments
 var sentence = str.split(" ");
 console.log("sentence " + sentence); 

// search for the second argument in the first argument
   var indexBefore = sentence.indexOf(before);
   console.log("indexBefore " + indexBefore);

// splice the third argument in its place
   sentence.splice(indexBefore, 1, after);
   var finalSentence = sentence.join(" ");
   console.log(finalSentence);

 return finalSentence;
}

replace("He is Sleeping on the couch", "Sleeping", "sitting");
Jonathan Lee
@Jwing28
Aug 13 2015 18:50
i tried asking my question on stack overflow but they probably thing i am stupid
Benjamin
@b1ggb3n86
Aug 13 2015 18:51
i was going to make a new array using .push() but i would have to use a for loop anyway
rbunz
@rbunz08
Aug 13 2015 18:51
The answer should be He is Sitting on the couch @MathManiac0
Jonathan Lee
@Jwing28
Aug 13 2015 18:51
i hate asking questions on there because ppl dont think your question is good enough
flota113
@flota113
Aug 13 2015 18:51
@Jwing28 what is your questioned - just joined the conversation and hard to catch on ;)
*catch up
Jonathan Lee
@Jwing28
Aug 13 2015 18:52
my question is, lets say i have an array of objects, like this:
Samuel Hunter
@MathManiac0
Aug 13 2015 18:52
@rbunz08 Try if (before[0].test(/[A-Z]/) after[0] = after[0].toUpperCase();
No idea if that's gonna work
Want me to explain it?
Jonathan Lee
@Jwing28
Aug 13 2015 18:53
var bookCase = [{title:'Book One',pages:234},{title:'Book Two',pages:4234},{title:'Book Three',pages:26534},{title:'Book Four',pages:34},{title:'Book Five',pages:2}];
i was trying to use reduce like this:
Samuel Hunter
@MathManiac0
Aug 13 2015 18:53
if (before[0].test(/[A-Z]/)
  after = after[0].toUpperCase() + after.slice(1, after.length); //If not working; try after.length-1
rbunz
@rbunz08
Aug 13 2015 18:53
@MathManiac0 yes please!! Where do I put this>
Jonathan Lee
@Jwing28
Aug 13 2015 18:53
var totalPages = bookCase.reduce(function(a,b,index){ return a[index].pages + b[index].pages},0);
Samuel Hunter
@MathManiac0
Aug 13 2015 18:53
@rbunz08 Put it at the beginning.
Jonathan Lee
@Jwing28
Aug 13 2015 18:54
error: cannot read property 'pages' of undefined
basically, i want to know how to access the values in each object
flota113
@flota113
Aug 13 2015 18:54
@Jwing28 Ok, I think I can help
Jonathan Lee
@Jwing28
Aug 13 2015 18:54
okay that would be great =)
Samuel Hunter
@MathManiac0
Aug 13 2015 18:54
It's pretty much saying that if the first letter of before is upper case, then replace after with itself, first letter turned into upper case.
@rbunz08
rbunz
@rbunz08
Aug 13 2015 18:55
@MathManiac0 ok... it said before[0].test is not a function
Samuel Hunter
@MathManiac0
Aug 13 2015 18:56
@rbunz08 What about /[A-Z/.test(before[0])
flota113
@flota113
Aug 13 2015 18:56
ok so a hold a previous value and b is current value
Samuel Hunter
@MathManiac0
Aug 13 2015 18:56
.test*
flota113
@flota113
Aug 13 2015 18:56
actuallly I will write everything to keep it in one place :p so let me have a minute ;)
rbunz
@rbunz08
Aug 13 2015 18:56
@MathManiac0 no it didnt like that
Samuel Hunter
@MathManiac0
Aug 13 2015 18:57
@rbunz08 What did it say?
Oh! I menat /[A-Z]/ not /[A-Z/
Jonathan Lee
@Jwing28
Aug 13 2015 18:58
@flota113 sure
Feners4
@Feners4
Aug 13 2015 18:59
can I get some help with getting my user input box to work and query whatever is typed in wiki api: http://codepen.io/Feners4/pen/ZGZORX
rbunz
@rbunz08
Aug 13 2015 18:59
@MathManiac0 Got it!! Thank-you!! When do we learn about regex??
Samuel Hunter
@MathManiac0
Aug 13 2015 18:59
@rbunz08 Near the end of the Javascript part of the tutorial.
Also known as regular expressions
I wouldn't recommend the codeacademy tutorial for it... It's too confusing.
rbunz
@rbunz08
Aug 13 2015 19:01
@MathManiac0 okay Thanks!
Samuel Hunter
@MathManiac0
Aug 13 2015 19:04
Just curious: Was that a bonfire?
Jason Ingram
@jsoningram
Aug 13 2015 19:05
This message was deleted
rbunz
@rbunz08
Aug 13 2015 19:05
@MathManiac0 Yep..number 22 I believe
Samuel Hunter
@MathManiac0
Aug 13 2015 19:06
Ah
On #17 right now
rbunz
@rbunz08
Aug 13 2015 19:06
@MathManiac0 Im doing better but I seem to forget the stuff I did earlier on..
Samuel Hunter
@MathManiac0
Aug 13 2015 19:06
Yeah... That happens...
Omar
@oab00
Aug 13 2015 19:06

@Feners4 add this to controler

$scope.changedTxt = function() {
    console.log($scope.searchTxt);
};

and this to input in html ng-change='changedTxt()'

rbunz
@rbunz08
Aug 13 2015 19:06
Like if I havent done it within the last few weeks its gone haha
Samuel Hunter
@MathManiac0
Aug 13 2015 19:07
Whenever I see myself checking stuff over and over again, I tend to print it out to have it by me.
One big think I have trouble remembering are regexes.
Jason Ingram
@jsoningram
Aug 13 2015 19:07
I'm having trouble with Sum All Primes. Any help is greatly appreciated.
function sumPrimes(num) {
    var primes = [],
        count = [],
        prep = [],
        i,
        j,
        k,
        l = 0,
        prime = true;

        prep[0] = 2;

    // is number natural (1,2,3,4) not real (1.234, 2.345)
    function isNatural( val ) {
        return ( (val > 0) && (Math.floor(val) == val) );
    }

    // push each number up to and including the number to count array
    for (i = 1; i <= num; i++) {
        count.push(i);
    }

    // weed out the ones that divide by 2 evenly
    for (j = 2; j < num; j++) {
        if (count[j] % 2 !== 0) {
            prep.push(count[j]);
        }
    }

    // push each real number to primes array
    for (k = 0; k < prep.length; k++) {
        if (!isNatural(Math.sqrt(prep[k]))) {
            primes.push(prep[k]);   
        }
    }

    console.log(primes);

    // add all numbers in primes array
    return primes.reduce(function(preVal, curVal) {
        return preVal + curVal;
    });
}

sumPrimes(10);
rbunz
@rbunz08
Aug 13 2015 19:07
@MathManiac0 thats a good idea... I just try to save everything in word documents so I can go back if I need to
flota113
@flota113
Aug 13 2015 19:08
@MathManiac0 I can ensure You that You are going to remember it for a long time if You keep practicing ;)
Samuel Hunter
@MathManiac0
Aug 13 2015 19:08
Oh yeah. That practice thing
Problem is that I only seem to use regexes in programming exercises.
And even then, out of the blue.
Benjamin
@b1ggb3n86
Aug 13 2015 19:08
so, can anybody explain how to use .reduce on "sum all numbers" bonfire?
here's my workaround...
function sumAll(arr) {
  var maxNum = Math.max.apply(null, arr);
  var minNum = Math.min.apply(null, arr);
  var total = 0;

  for(i = minNum; i <= maxNum; i++) {
    total += i;
  }
  return(total);
}

sumAll([1, 4]);
flota113
@flota113
Aug 13 2015 19:09
@MathManiac0 have to agree :/
Cody Bouscaren
@codybousc
Aug 13 2015 19:09
Hi all, I'm making a mess of Bonfire#20. Any suggestions?
function diff(arr1, arr2) {
  var newArr = [];
    //sorts the arrays 
    var sortedArr1 = arr1.sort(function(a, b){return a-b});
    var sortedArr2 = arr2.sort(function(a, b){return a-b});

    //Finds array longest in length 
      var longest; 
      var shortest;
      if(arr1.length > arr2.length) {
          longest = sortedArr1;
          shortest = sortedArr2;
      }
      else {
           longest = sortedArr2;
           shortest = sortedArr1;
      }
            var originalLength = longest.length
     for (var i = 0; i < originalLength; i++) {
         console.log('LONGEST', longest[i]);
         for (var j = 0; j < shortest.length; j++) {
             console.log('SHORTEST', shortest[j]);
             if (longest[i] === shortest[j]) {
                 if (longest.length <= 2) {
                  console.log("MADE IT TO THE NESTED IF: " + longest.pop());
                  console.log("NEW LONGEST: " + longest);

                 }
                 else {
                 console.log("LONGEST MATCH: " + longest[i], "SHORTEST MATCH: " + shortest[j]);
                 console.log("REMOVING: " + longest.splice(longest[i], 1));//problem here 
                 shortest.splice(longest[i]); 
                 console.log("NEW LONGEST: " + longest);
                 }

             }
         }     

     } //outer for loop closing tag  

     return longest; 
}

console.log(diff(['andesite', 'grass', 'dirt', 'pink wool', 'dead shrub'], ['diorite', 'andesite', 'grass', 'dirt', 'dead shrub']));
Samuel Hunter
@MathManiac0
Aug 13 2015 19:09
Do I see Minecraft blocks above?
flota113
@flota113
Aug 13 2015 19:09
@b1ggb3n86 have You read https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce - Mozzila's docs usally have pretty good examples
@b1ggb3n86 I'm asking because it's always better to figure it out yourself and to be honest there's even Your example ;)
Feners4
@Feners4
Aug 13 2015 19:11
@oab00 great! thank you very much for that, I kept trying to get this to work I without success..
Benjamin
@b1ggb3n86
Aug 13 2015 19:12
@flota113 Yes. I get how it's used. But I wanted to know how it is implemented in this bf. The only way I could think was making a for loop to create a new array, but at that point I would just be adding more code than my original.
i beat the bf. i just want to make sure I'm learning what they are trying to teach me.
i get using reduce() with a full array, but not how to use it with just two numbers to give me the sum of all numbers, without redundant code that is...
Omar
@oab00
Aug 13 2015 19:14
@Feners4 anytime :)
flota113
@flota113
Aug 13 2015 19:18
@b1ggb3n86 this is 19th bf?
Benjamin
@b1ggb3n86
Aug 13 2015 19:18
yes
@flota113
like i said. the only way i found i could use reduce() is by creating a new array using a for loop.
at that point it's kind of redundant because i can solve using a for loop. so i wanted to know how others implemented reduce() for this bf
Matthew Senko
@mpskierbg
Aug 13 2015 19:22
```
flota113
@flota113
Aug 13 2015 19:22
@b1ggb3n86 sorry, to be honest I didn't check what bonfire You talked about - now I see what You mean ;)
Benjamin
@b1ggb3n86
Aug 13 2015 19:23
@flota113 No worries. So I'm not missing anything? You have to use a for loop anyway?
flota113
@flota113
Aug 13 2015 19:24
@b1ggb3n86 maybe there is some way - I also used for loop in this challenge - and don't think that doing some hack with reduce would be recommended 'cos I guess it would overcomplicate things ;)
Matthew Senko
@mpskierbg
Aug 13 2015 19:25
     for(var j = 0; j<fibarr.length; j++){
              if(fibarr[j] % 2 !== 0){
                  n = n+ j;
              }
          }  
       return n;
}

sumFibs(4);
so the array im iterating through is [1,1,2,3] the above returns 4. I want it to return the sum of all the odd so it should be 5. what is wrong with it?
Benjamin
@b1ggb3n86
Aug 13 2015 19:25
ok. thank you @flota113
flota113
@flota113
Aug 13 2015 19:26
@b1ggb3n86 I haven't helped so don't thank me at all ;)
Mike Moss
@MMux
Aug 13 2015 19:27
Just finished (i think!) the Random Quote zipline: http://codepen.io/MMux/full/xGeVqE/
  • however i'm getting a console error for the web intent tweet, even though it's populating the quote correctly. If anyone has an idea of why, would love the breakdown on it.
Brett Guillory
@kurzninja
Aug 13 2015 19:30
@MMux that's a great looking page
I'm having the same Twitter problem issue on mine right now
Nic Galluzzo
@ngalluzzo
Aug 13 2015 19:30
good job @MMux
Samuel Hunter
@MathManiac0
Aug 13 2015 19:31
@MMux Awesome webpage! ...although you should probably remove some of the borderline quotes.
Brett Guillory
@kurzninja
Aug 13 2015 19:32
borderline?
flota113
@flota113
Aug 13 2015 19:32
@MMux it look nice - I just added console.log() to the tweet intent and it looks it's being called twice ;)
Samuel Hunter
@MathManiac0
Aug 13 2015 19:32
Well, anything revolving around religion, etc. can be considered pretty offensive to some people.
Brett Guillory
@kurzninja
Aug 13 2015 19:33
@MathManiac0 I don't think that's under his control, since the quotes are random
besides, let people be offended, it doesn't hurt them :P
@MMux your footer text is almost impossible to read because of the color
flota113
@flota113
Aug 13 2015 19:36
@MMux on line 30 (in codepen) You call tweetIntent without the data so data.quote is undefined and it's where Your error comes from ;)
Mike Moss
@MMux
Aug 13 2015 19:36
@flota113 thanks! I was wondering what was going on.
@kurzninja thx; will brighten up the text a little bit on the footer. still wanting to keep it subtle.
flota113
@flota113
Aug 13 2015 19:38
@MMux no problem ;)
Brett Guillory
@kurzninja
Aug 13 2015 19:38
I understand, it's just a little TOO subtle ;)
Mike Moss
@MMux
Aug 13 2015 19:38
@kurzninja the web intents docs are not that clear.
Brett Guillory
@kurzninja
Aug 13 2015 19:38
the problem with the Twitter button is the same that I'm having
Twitter's script turns the <a> into an <iframe>
so you can't access the href attribute of the link anymore
I haven't found a solution YET....
Mike Moss
@MMux
Aug 13 2015 19:39
@kurzninja i originally used the script; but i found a small script in the docs:
flota113
@flota113
Aug 13 2015 19:39
@kurzninja but actually @MMux's button works ;) his problem was different he got undefined error
Mike Moss
@MMux
Aug 13 2015 19:39
twttr.ready(function() {
twttr.widgets.load(document.getElementById("tweet"));
});
Brett Guillory
@kurzninja
Aug 13 2015 19:39
oh
d'oh
@MMux can you link me to where you found that doc?
Brett Guillory
@kurzninja
Aug 13 2015 19:41
gracias
Mike Moss
@MMux
Aug 13 2015 19:41
i don't even know how i found it, but it helped
Stein Gee
@Stiino0
Aug 13 2015 19:42
bonfire diff
CamperBot
@camperbot
Aug 13 2015 19:42

:fire:Bonfire: Diff Two Arrays :link:

function diff(arr1, arr2) {
  var newArr = [];
  // Same, same; but different.
  return newArr;
}

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

Compare two arrays and return a new array with any items not found in both of the original arrays.

more info:  bf details | bf links | hint

Stein Gee
@Stiino0
Aug 13 2015 19:42
Hey guys, I was wondering how to tackle this one. Can anyone assist?
Samuel Hunter
@MathManiac0
Aug 13 2015 19:43
Woah @camperbot can read our minds
Or chat
Stein Gee
@Stiino0
Aug 13 2015 19:43
Would it be a good way to "merge" the 2 arrays, then check if the value is only presented once? or would't that be the best way?
Nicholas
@nick88p
Aug 13 2015 19:44
Hmm ... that's something I haven't tried.
Mike Moss
@MMux
Aug 13 2015 19:44
@Stiino0 that's what i did
worked for me
Stein Gee
@Stiino0
Aug 13 2015 19:44
@MMux I'll give it a try, mind assisting me when I go wrong? :d
Mike Moss
@MMux
Aug 13 2015 19:45
@Stiino0 sure, if i can remember :)
Stein Gee
@Stiino0
Aug 13 2015 19:45
@nick88p what did you try then? just explanation, no code!
you can always relook your code in ur FCC profile
Nicholas
@nick88p
Aug 13 2015 19:46
Loads. I was primarily trying to solve the problem with for loops.
Stein Gee
@Stiino0
Aug 13 2015 19:46
by clicking on your current "score" in the upper right corner on FCC
@nick88p I was first thinking about doing the same
Dayne Wright
@daynewright
Aug 13 2015 19:46
How would I get to the thumbnail link on this JSON object?
http://en.wikipedia.org/w/api.php?action=query&titles=Al-Farabi&prop=pageimages&format=json&pithumbsize=100
Valid
Formatted JSON Data
{
   "batchcomplete":"",
   "query":{
      "pages":{
         "175040":{
            "pageid":175040,
            "ns":0,
            "title":"Al-Farabi",
            "thumbnail":{
               "source":"https://upload.wikimedia.org/wikipedia/commons/thumb/5/55/Al-Farabi.jpg/80px-Al-Farabi.jpg",
               "width":80,
               "height":100
            },
            "pageimage":"Al-Farabi.jpg"
         }
      }
   }
}
Stein Gee
@Stiino0
Aug 13 2015 19:47
function diff(arr1, arr2) {
  var newArr = [];

  for (i=0;i<arguments.length;i++) {
    for (j=0;j<arr1.length;j++) {
      if (arr1[j] != arr2[j]){
        newArr.push(arr1[j]);
      }
    }
  }

  return newArr;
}

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
That's where I was @ when I had the idea of merging then looking if it was showing multiple times or not
Justin Rogers
@yaskyj
Aug 13 2015 19:47
@Stiino0 You could run a filter over each with indexOf from the other array, then concat the resulting arrays together.
Nicholas
@nick88p
Aug 13 2015 19:48
@Stiino0 I had something similar. But the problem is it pushes too many values, right?j
Stein Gee
@Stiino0
Aug 13 2015 19:48
It's the filter method that I don't completely understand. I mean I get how it works but never know how to implement in the requested challenges :s
Babs Craig
@babzcraig
Aug 13 2015 19:48
Hello guys. I'm having a problem with the Return Largest Number Bonfire. Is anyone here able to help
Stein Gee
@Stiino0
Aug 13 2015 19:48
@nick88p not right now, isn't nearly working ftm
bonfire return largest number
CamperBot
@camperbot
Aug 13 2015 19:48

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

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

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

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

more info:  bf details | bf links | hint

Babs Craig
@babzcraig
Aug 13 2015 19:49
I can print through the array and sub array but can't figure out how to compare the values and then pass them into a string
@camperbot that's it
Moisés Man
@moigithub
Aug 13 2015 19:49
@camperbot is a bot :)
Babs Craig
@babzcraig
Aug 13 2015 19:49
Hahahahaaa.... I'm such a noooooob
Stein Gee
@Stiino0
Aug 13 2015 19:49
@babzcraig I summoned camperbot :D by typing the text bon fire return largest number
without the space between bon and fire
Samuel Hunter
@MathManiac0
Aug 13 2015 19:50
bonfire where art thou
CamperBot
@camperbot
Aug 13 2015 19:50

:fire:Bonfire: Where art thou :link:

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

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

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

more info:  bf details | bf links | hint

Samuel Hunter
@MathManiac0
Aug 13 2015 19:50
Amazing
Babs Craig
@babzcraig
Aug 13 2015 19:50
Anyone able to help me with this?
Stein Gee
@Stiino0
Aug 13 2015 19:51
Try showing your code by entering three backticks, then the code and Ctrl or CMD enter to show the code
Mike Moss
@MMux
Aug 13 2015 19:51
@Daynewr look at the url in chrome. You'll see bottom right the hierarchy: query.pages.175040.thumbnail
Stein Gee
@Stiino0
Aug 13 2015 19:51
```
Justin Rogers
@yaskyj
Aug 13 2015 19:51

@Stiino0 Filter just runs a check over the array and returns anything that meets that check so something like:

[1, 2, 3, 4, 5].filter(function(a) {
  return a < 4;
});

Would return an array of [1, 2, 3]

Stein Gee
@Stiino0
Aug 13 2015 19:51
those are backticks @babzcraig
@yaskyj that I understand, however the next part(s) I miss
but
Justin Rogers
@yaskyj
Aug 13 2015 19:53
@Stiino0 If you were to combine that with an indexOf === -1 on the other array, it would return everything not found.
Stein Gee
@Stiino0
Aug 13 2015 19:54
if I were to merge both arrays and in my function I would state something like: if indexOf a.length is less
oh wow
that's what I had in mind except I didn't know indexOf === -1 would then return everything not found :D
I'll give this method a try
Cya in a bit guys :)
Justin Rogers
@yaskyj
Aug 13 2015 19:54
Yeah, if something isn't found in an array indexOf returns -1
Babs Craig
@babzcraig
Aug 13 2015 19:55
This message was deleted
Stein Gee
@Stiino0
Aug 13 2015 19:55
almost @babzcraig , I usually try to start with the backticks
Babs Craig
@babzcraig
Aug 13 2015 19:56
This message was deleted
Joanna Georgescu
@joannatg
Aug 13 2015 19:56
How to crack the roman numeral converter bf? A high level hint anyone? no code sharing pls
Stein Gee
@Stiino0
Aug 13 2015 19:56
hit enter after the backticks
THEN insert code!
try editing the post
or delete lol
Babs Craig
@babzcraig
Aug 13 2015 19:56
```
Aaaargh
Stein Gee
@Stiino0
Aug 13 2015 19:56
Haha
Babs Craig
@babzcraig
Aug 13 2015 19:56

```function largestOfFour(arr) {
// You can do this! Yes I can!!

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

var subArr = arr[i];
var m = 0;

for (var j = 0; j < subArr.length; j++) {
if (subArr[j] > m) {
  m = subArr[j];
}
  console.log(m);


}

}
}

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

Stein Gee
@Stiino0
Aug 13 2015 19:56
I don't understand
I can press enter after the backticks, then a second pair of backticks on the third line appear and I can paste code
Justin Rogers
@yaskyj
Aug 13 2015 19:57
@babzcraig You can also switch to compose mode by useing Ctrl + / or by clicking in the lower right hand corner of the box.
Stein Gee
@Stiino0
Aug 13 2015 19:57
THIS IS GOING TO BE CODE
Babs Craig
@babzcraig
Aug 13 2015 19:57
This message was deleted

```function largestOfFour(arr) {
// You can do this! Yes I can!!

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

var subArr = arr[i];
var m = 0;

for (var j = 0; j < subArr.length; j++) {
if (subArr[j] > m) {
  m = subArr[j];
}
  console.log(m);


}

}
}

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

Stein Gee
@Stiino0
Aug 13 2015 19:58
need enter after the first backticks

Mistereo
@Mistereo
Aug 13 2015 19:58
help code
Stein Gee
@Stiino0
Aug 13 2015 19:58
help markup
Joris Labie
@labiej
Aug 13 2015 19:58
help format
Babs Craig
@babzcraig
Aug 13 2015 19:58
I can't figure out how to compare the highest values, save that value and the place it in a new array
function largestOfFour(arr) {
  // You can do this! Yes I can!!

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

    var subArr = arr[i];
    var m = 0;

    for (var j = 0; j < subArr.length; j++) {
    if (subArr[j] > m) {
      m = subArr[j];
    }
      console.log(m);


    }
}
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Stein Gee
@Stiino0
Aug 13 2015 19:59
:+1:
Joris Labie
@labiej
Aug 13 2015 19:59
you winneded
Babs Craig
@babzcraig
Aug 13 2015 19:59
Finally. lol. Thanks @Stiino0
Stein Gee
@Stiino0
Aug 13 2015 19:59
great job, you're welcome!
Now people can read ur code. Good luck!
Babs Craig
@babzcraig
Aug 13 2015 20:00
Thanks. Hope someone helps. It's late here and I want to complete a couple more bonfires before heading to bed
gravesr1993
@gravesr1993
Aug 13 2015 20:00
so, could anyone look at this and give me a clue why the last condition is failing? it seems to be returning undefined correctly in log and under run code
Feners4
@Feners4
Aug 13 2015 20:01
@oab00 I'm having difficulties implementing correctly the method you gave me.. I cant get it to run my function every time the text changes...
Omar
@oab00
Aug 13 2015 20:04
@Feners4 looked at the codepen, seems like you put the function inside an if statement?
that if statement only runs once, you should put it the other way around
so make the if statement inside the function
Justin Rogers
@yaskyj
Aug 13 2015 20:05
@babzcraig Are you familiar with the sort and reduce functions?
Babs Craig
@babzcraig
Aug 13 2015 20:11
No, I'm not
Ozy Design & Software
@OzySky
Aug 13 2015 20:11
@gravesr1993 can you paste your code?
Babs Craig
@babzcraig
Aug 13 2015 20:11
@yaskyj
Justin Rogers
@yaskyj
Aug 13 2015 20:13
@babzcraig What's up?
Feners4
@Feners4
Aug 13 2015 20:14
@oab00 i kinda tried that too, but let me work something out and see if it works..
Dayne Wright
@daynewright
Aug 13 2015 20:15
Anyone want to help me with this zipline? Just getting the fade to work correctly: http://codepen.io/daynewr/pen/jPRMNL
flota113
@flota113
Aug 13 2015 20:16
@Daynewr what You mean by working correctly? because it already fades nicely ;)
Dayne Wright
@daynewright
Aug 13 2015 20:17
@flota113 I guess I am asking more of the question about how I coded it
seems like there is a better way then adding fadeOut fadeIn over and over
Cody Bouscaren
@codybousc
Aug 13 2015 20:18
Can someone please offer some advice ? When I run my code on JSfiddle, it passes all of the specs provided by Bonfire #20, but when I run the code in the Bonfire console two out of seven tests pass?!
function diff(arr1, arr2) {
  var newArr = [];
    //sorts the arrays 
    var sortedArr1 = arr1.sort(function(a, b){return a-b});
    var sortedArr2 = arr2.sort(function(a, b){return a-b});

    //Finds array longest in length 
      var longest; 
      var shortest;
      if(arr1.length > arr2.length) {
          longest = sortedArr1;
          shortest = sortedArr2;
      }
      else {
           longest = sortedArr2;
           shortest = sortedArr1;
      }
         var longOriginalLength = longest.length;
         var shortOriginalLength = shortest.length;
     for (var i = longOriginalLength - 1; i >= 0; i--) {
         console.log('LONGEST', longest[i]);
         for (var j = shortOriginalLength - 1; j >= 0; j--) {
             console.log('SHORTEST', shortest[j]);
             if (longest[i] === shortest[j]) {
                 console.log("LONGEST MATCH: " + longest[i], "SHORTEST MATCH: " + shortest[j]);
                 var removeL = longest.indexOf(longest[i]); 
                 var removeS = shortest.indexOf(shortest[j]); 
                 console.log("REMOVING: " + longest.splice(removeL, 1));//problem here 
                 shortest.splice(removeS, 1);
                 console.log("NEW LONGEST: " + longest);
                 }

             }    

     } //outer for loop closing tag  
     if (arr1.length === arr2.length) {
         var answer = shortest.concat(longest);
         return answer;
     }
     else {
     return longest;
     }
}

console.log(diff([1, 'calf', 3, 'piglet'], [1, 'calf', 3, 4]));
Feners4
@Feners4
Aug 13 2015 20:19
@oab00 now I got it to work!
Cody Bouscaren
@codybousc
Aug 13 2015 20:19
and the console.logs scattered throughout the code are only there to help me figure out what the nested for loops were doing
Matthew Senko
@mpskierbg
Aug 13 2015 20:19
alright guys im stuck how do i write an iteration to get all prime numbers less than or equal to the passed number?
flota113
@flota113
Aug 13 2015 20:21
@Daynewr it doesn't look back and also I see You already written function for fading out , you could also write one for fading in
Omar
@oab00
Aug 13 2015 20:22
@Feners4 congratz!
now if you want to only search after pressing enter: remove ng-change and change the
function in the form ng-submit to call the function that was in ng-change
flota113
@flota113
Aug 13 2015 20:22
@Daynewr to be honest my code usually get's messed up because in the end I want sth quickly to work and forget about clean code :/ so.. :p
Dayne Wright
@daynewright
Aug 13 2015 20:22
@flota113 No problem :)
Ozy Design & Software
@OzySky
Aug 13 2015 20:23
@codybousc your function returns the diff reversed ( for e.g diff(['andesite', 'grass', 'dirt', 'pink wool', 'dead shrub'], ['diorite', 'andesite', 'grass', 'dirt', 'dead shrub']) returns ['pink wool', 'diorite'] instead of ['diorite', 'pink wool']
Cody Bouscaren
@codybousc
Aug 13 2015 20:25
@ozydesign so i just reversed the order as you suggested, but all 5 out of 7 tests are still failing
Samuel Hunter
@MathManiac0
Aug 13 2015 20:26
What if you .sort()?
Ozy Design & Software
@OzySky
Aug 13 2015 20:26
@codybousc that won't work since it isn't just reversed- it's sorted - so reversing again won't work
Cody Bouscaren
@codybousc
Aug 13 2015 20:28
@ozydesign I changed order of the array concat in the final 'if' statement.
function diff(arr1, arr2) {
  var newArr = [];
    //sorts the arrays 
    var sortedArr1 = arr1.sort(function(a, b){return a-b});
    var sortedArr2 = arr2.sort(function(a, b){return a-b});

    //Finds array longest in length 
      var longest; 
      var shortest;
      if(arr1.length > arr2.length) {
          longest = sortedArr1;
          shortest = sortedArr2;
      }
      else {
           longest = sortedArr2;
           shortest = sortedArr1;
      }
         var longOriginalLength = longest.length;
         var shortOriginalLength = shortest.length;
     for (var i = longOriginalLength - 1; i >= 0; i--) {
         console.log('LONGEST', longest[i]);
         for (var j = shortOriginalLength - 1; j >= 0; j--) {
             console.log('SHORTEST', shortest[j]);
             if (longest[i] === shortest[j]) {
                 console.log("LONGEST MATCH: " + longest[i], "SHORTEST MATCH: " + shortest[j]);
                 var removeL = longest.indexOf(longest[i]); 
                 var removeS = shortest.indexOf(shortest[j]); 
                 console.log("REMOVING: " + longest.splice(removeL, 1));//problem here 
                 shortest.splice(removeS, 1);
                 console.log("NEW LONGEST: " + longest);
                 }

             }    

     } //outer for loop closing tag  
     if (arr1.length === arr2.length) {
         var answer = longest.concat(shortest);// This is what I changed!!!
         return answer;
     }
     else {
     return longest;
     }
}
is there something else that i should do?
i'm also confused since this should only affect one of the five failing tests
or should i do away with the sorting altogether?
Ozy Design & Software
@OzySky
Aug 13 2015 20:33
@codybousc try removing the console.log
Cody Bouscaren
@codybousc
Aug 13 2015 20:36
@ozydesign that did it!!!!!
thank you so much
Ozy Design & Software
@OzySky
Aug 13 2015 20:36
@codybousc no problems
Cody Bouscaren
@codybousc
Aug 13 2015 20:36
i've been stuck on this bonfire for almost 5 hours! grrrrr
Sylvester
@impreze
Aug 13 2015 20:37
I have a question about "Bonfire: Smallest Common Multiple" if anyone can help.
Feners4
@Feners4
Aug 13 2015 20:37
@oab00 ah!thanks for that tip!
@oab00 awesome of you to point that out..
Omar
@oab00
Aug 13 2015 20:39
sorry to make u use ng-change didn't see u had ng-submit waiting there all along
Luis Felipe López G.
@luishendrix92
Aug 13 2015 20:39
bf smallest common
CamperBot
@camperbot
Aug 13 2015 20:39

:fire:Bonfire: Smallest Common Multiple :link:

function smallestCommons(arr) {
  return arr;
}


smallestCommons([1,5]);

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

more info:  bf details | bf links | hint

Teejay Parker
@TeejayParker
Aug 13 2015 20:40
If anyone knows PHP & CSS better than I do, I could use a hand with the PlugDJ stylizing. https://github.com/Majeye/majeye.github.io
can't seem to get the custom chat badges to work
Feel free to push/pull to that repo
Kalidh Mohamed
@snipermk0
Aug 13 2015 20:40
ok so how do I center align the trash can and text? <div class='col-xs-4'>
<button class='btn btn-block btn-danger'><i class='fa fa-trash'></i> Delete</button>
</div>
Sylvester
@impreze
Aug 13 2015 20:41
The smallest common multiple of [1,5] would be 5 correct? I haven't forgotten that much from school. However my submission is displaying that the SCM should be 60..
Hass anyone experienced that?
Luis Felipe López G.
@luishendrix92
Aug 13 2015 20:42
@impreze It doesn't take 1 and 5 as "least common multiple of 1 and 5", they expect you to use the 1 and 5 as a range lol, like: 1, 2, 3, 4, 5
Ozy Design & Software
@OzySky
Aug 13 2015 20:43
so the lowest number that divides evenly by all of those number - is 60
Sylvester
@impreze
Aug 13 2015 20:43
@luishendrix92 ah i see. Thanks.
gotbing
@gotbing
Aug 13 2015 20:43
Anyone do exact change? I feel like my code is working properly, but not outputting the correct format for it to "deeply equal" what they are expecting
Luis Felipe López G.
@luishendrix92
Aug 13 2015 20:44
I pre-solved that with this article: http://www.wikihow.com/Find-the-Least-Common-Multiple-of-Two-Numbers
I remember how to do that but I needed a faster method.
Krzysztof Miąsko
@kmiasko
Aug 13 2015 20:44
@gotbing take a look at rounding floating point numbers
Rob
@BobsHub
Aug 13 2015 20:45
regarding udacity course on objects I cannot find it using the links
is it meant to be only 2 videos?
gotbing
@gotbing
Aug 13 2015 20:46
function drawer(price, cash, cid) {

    var changeAmt = cash - price,
        change = changeAmt,

        VALUE_MAP = {'PENNY' :0.01,
            'NICKEL':0.05,
            'DIME':0.1,
            'QUARTER':0.25,
            'ONE':1,
            'FIVE':5,
            'TEN':10,
            'TWENTY':20,
            'ONE HUNDRED':100},
        drawerTotal = cid.reduce(function (total, curr) {
            return total += curr[1];
        }, 0 );

    console.log(drawerTotal.toFixed(2));

    var results = cid.reverse().reduce(function (totalChange, curr, index) {

        var denomination = VALUE_MAP[curr[0]],
            denom_type = curr[0],
            amountInDrawer = curr[1],
            numChange = Math.floor(change/denomination) * denomination, 
            numDrawer = Math.floor(amountInDrawer/denomination) * denomination,
            reduceChange;

        // Check to see if there's enough in the drawer to go through change.
        if (denom_type === 'PENNY' ) {
          reduceChange = [denom_type, change.toFixed(2)];
        } else if (numDrawer < numChange) {
            reduceChange = [denom_type, numDrawer];
            change = change - numDrawer;
        } else {
            reduceChange = [denom_type, numChange];
            change = change - numChange;
        }

        // If using the current denomination, push it into the totalChange array
        if (numChange > 0 && numDrawer > 0) {

            totalChange.push(reduceChange);

            return totalChange;

        } else {

            return totalChange;
        }
    }, [] );

    if (change > drawerTotal) {

        return "Insufficient Funds";

    } else if (drawerTotal === changeAmt) {

        return "Closed";

    } else {

        return results;

    }


    // Here is your change, ma'am
}

// Example cash-in-drawer array:
// [['PENNY', 1.01],
// ['NICKEL', 2.05],
// ['DIME', 3.10],
// ['QUARTER', 4.25],
// ['ONE', 90.00],
// ['FIVE', 55.00],
// ['TEN', 20.00],
// ['TWENTY', 60.00],
// ['ONE HUNDRED', 100.00]]

drawer(3.26, 100.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]);
Rob
@BobsHub
Aug 13 2015 20:47
spammers
annoying
flota113
@flota113
Aug 13 2015 20:49
@BobsHub above video there are buttons - You noticed them, right? there's nothing more - at least in the section You are looking at ;)
Rob
@BobsHub
Aug 13 2015 20:50
ok thanks, I thought it was a complete course on objects
flota113
@flota113
Aug 13 2015 20:50
@gotbing I don't think You want to do Math.floor and instead You probably would like to use Math.round
@gotbing becuase if the float error will result in 1.989789 You would like to get 2 instead of 1 ;)
gotbing
@gotbing
Aug 13 2015 20:52
@flota113 all my values are correct for the test case, it's just not displaying it how the solver wants it I think. ['ONE', 1] vs ['ONE', 1.00]
flota113
@flota113
Aug 13 2015 20:52
@gotbing Oh now I see that You use it for sth different -
ahh...
are You sure it's just that?
gotbing
@gotbing
Aug 13 2015 20:52
that's what it looks like, the change outputted matches the change that would/should be given
Krzysztof Miąsko
@kmiasko
Aug 13 2015 20:53
@gotbing i don't think so
or maybe they are :D
gotbing
@gotbing
Aug 13 2015 20:55
[['TWENTY', 60.00], ['TEN', 20.00], ['FIVE', 15], ['ONE', 1], ['QUARTER', 0.50], ['DIME', 0.20], ['PENNY', 0.04] ]
like, it mixes between
.isFixed(2)
and not
that is what the solver seems to expect ^
Russell Westberry
@russbus
Aug 13 2015 20:57
So I'm working on this roman numeral thing and I feel like my code is hacky/poor. Not sure if that's just because my brain broke and I've spent the better part of the day staring at it or if it's actually bad.
Omar
@oab00
Aug 13 2015 20:57
@gotbing u can use parseFloat(integer)
Krzysztof Miąsko
@kmiasko
Aug 13 2015 20:57
@gotbing strange, last one shows as a string http://i.imgur.com/KiEAKME.png
Samuel Hunter
@MathManiac0
Aug 13 2015 20:57
@russbus You kidding? Just passed that and I had about 8 if/elif's
Ozy Design & Software
@OzySky
Aug 13 2015 20:58
@russbus you can post your code on FreeCodeCamp/CodeReview channel if you want
gotbing
@gotbing
Aug 13 2015 20:58
@kmiasko yeah I was messing around with adding .isFixed(2) which returns a string
flota113
@flota113
Aug 13 2015 20:58
@gotbing checked the tests for the task and it compares number so it's definitely not format
because when comparing numbers it doesn't depend on it
I will run Your solution in a moment and see if I can find sth
Omar
@oab00
Aug 13 2015 20:59
it is format I used a map function with parseFloat on the return and his function worked :sweat_smile:
return results.map(function(a) { return [a[0], parseFloat(a[1])]; });
gotbing
@gotbing
Aug 13 2015 21:03
@oab00 ah, thanks. I just added the parseFloat to the ['PENNY'] amount and it worked.
a little mix of everything. I forgot toFixed() returns a string. But I had the right "value"
Samuel Hunter
@MathManiac0
Aug 13 2015 21:04
Can somebody help me with a regex pattern I'm having trouble making
gotbing
@gotbing
Aug 13 2015 21:04
passed, it, albeit, probably a little hacky, but thanks guys
Babs Craig
@babzcraig
Aug 13 2015 21:05
thanks @Stiino0
CamperBot
@camperbot
Aug 13 2015 21:05
babzcraig sends brownie points to @stiino0 :sparkles: :thumbsup: :sparkles:
hey @babzcraig if you found this info helpful :point_right: consider adding a wiki article!
:star: 9 | @stiino0 | http://www.freecodecamp.com/stiino0
Babs Craig
@babzcraig
Aug 13 2015 21:05
You're awesome!
Stein Gee
@Stiino0
Aug 13 2015 21:06
Dalu, @babzcraig Kachifo!!
(I hope I haven't offended you now lol)
flota113
@flota113
Aug 13 2015 21:07
@MathManiac0 will try to ;)
Samuel Hunter
@MathManiac0
Aug 13 2015 21:07
So, I'm trying to select the first consonants of a word, stopping at and excluding the frist vowel
It's for the Pig Latin bonfire I'm trying to solve
Russell Westberry
@russbus
Aug 13 2015 21:08
@ozydesign I didn't even know that was a channel. Neat.
Samuel Hunter
@MathManiac0
Aug 13 2015 21:08
I have the best I can come up with here: http://regexr.com/3bj6a
flota113
@flota113
Aug 13 2015 21:08
had to check what "consonants" means :DD
Samuel Hunter
@MathManiac0
Aug 13 2015 21:08
Not vowels
Not aeiou
flota113
@flota113
Aug 13 2015 21:08
Now I know ;)
Luis Felipe López G.
@luishendrix92
Aug 13 2015 21:09
@MathManiac0 /[^aeiou]/gi
^ inside square brackets means "anything that is NOT in this character set"
Samuel Hunter
@MathManiac0
Aug 13 2015 21:10
Awesome!
Babs Craig
@babzcraig
Aug 13 2015 21:10
@Stiino0 not at all, You got it right! Goede Nacht!
Ozy Design & Software
@OzySky
Aug 13 2015 21:10
@MathManiac0 \b([^aeiou\s]+)
@luishendrix92 oops
sorry
@luishendrix92 wont yours match even consonants that come in the middle of the word?
Luis Felipe López G.
@luishendrix92
Aug 13 2015 21:12
@ozydesign Yeah, to solve that bonfire I did something like var consonants = str.match(/^[^aeiou]+/i)
Samuel Hunter
@MathManiac0
Aug 13 2015 21:12
thanks @ozydesign ! Yours works!
CamperBot
@camperbot
Aug 13 2015 21:12
mathmaniac0 sends brownie points to @ozydesign :sparkles: :thumbsup: :sparkles:
hey @mathmaniac0 if you found this info helpful :point_right: consider adding a wiki article!
:star: 8 | @ozydesign | http://www.freecodecamp.com/ozydesign
Stein Gee
@Stiino0
Aug 13 2015 21:12
@babzcraig there are multiple dialects(?) so I wasn't sure :d happy coding!!
Luis Felipe López G.
@luishendrix92
Aug 13 2015 21:13
function translate(str) {
  var consonants = str.match(/^[^aeiou]+/i);
  if ( /[aeiou]/i.test(str[0]) )
    return str + 'way';
  else
    return str.slice(consonants[0].length) + consonants[0] + 'ay';
}

translate("consonant");
Ozy Design & Software
@OzySky
Aug 13 2015 21:14
@luishendrix92 but if two words were passed to that exp...
Luis Felipe López G.
@luishendrix92
Aug 13 2015 21:15
That's why I mentioned yesterday that I wanted to use a str.replace method instead, but I'm just relaxing here watching tv.
Samuel Hunter
@MathManiac0
Aug 13 2015 21:16
Well, here's my working code for Pig Latin:
function translate(str) {
 if(/^[a|e|i|o|u]+/.test(str))
    return str + 'way';
 else { 
   var cons = str.match(/\b([^aeiou\s]+)/gi)[0];
   return str.slice(cons.length, str.length) + cons + 'ay';
 }
}

translate("glove");
Luis Felipe López G.
@luishendrix92
Aug 13 2015 21:19
@MathManiac0 My chrome console messed up when I tried to put the [0] after .match() haha, that's why I moved mine after the variable name in the return statement.
Samuel Hunter
@MathManiac0
Aug 13 2015 21:20
I just realized that I didn't need to do /^[a|e|i|o|u]/... I just needed /^[aeiou]/.
amwakatsuki
@amwakatsuki
Aug 13 2015 21:21
I'm totally confused at what Bonfire Where Art Thou is asking for. Can someone point me in the right direction?
Luis Felipe López G.
@luishendrix92
Aug 13 2015 21:23
@amwakatsuki It wants you to return an array of objects (those objects are in the first argument passed to the function) that match the criteria of the second argument passed to the function ( { last: 'Capulet' } )
Samuel Hunter
@MathManiac0
Aug 13 2015 21:23
@amwakatsuki
--->
Anthony MacMahon
@SansPulp
Aug 13 2015 21:32
I'm doing Bonfire: Sum of all numbers, and I think my logic is right, but it's returning null. Can anyone help me decode this?
function sumAll(arr) {
  var range = [];

  //if the smallest number = arr[0], make a range counting up with a for loop
  if (Math.min(arr) == arr[0]) {
    for (i=arr[0]; i<arr[1]; i++) {
      //push that range to the variable range
      range.push(arr[i]);
    }  
  }
  //do the opposite, make a range counting down
    else {
      for (i=arr[1]; i>0; i--) {
        range.push(arr[i]);
      }
    }

  //add all the numbers in the new range and add them together
  var total = range.reduce(function(a, b) {
  return a + b;
  });
  return total;
}



sumAll([1, 4]);
Ryan Hiller
@Jechob
Aug 13 2015 21:33
Can someone try to explain the "Arguments Optional" bonfire a bit better to me? I have everything working except I'm not really sure what it's asking me to do if only one argument is passed.
KWells
@Susurrus19
Aug 13 2015 21:36
@SansPulp Math.min(arr) Won't work. That method cannot take an array as input unless the engine is using ECMAS 6. It will return NaN.
I am on the same bonfire at the moment.
Anthony MacMahon
@SansPulp
Aug 13 2015 21:38
@Susurrus19 Dang. I was so sure I had this one without looking at any kind of solutions.
Moisés Man
@moigithub
Aug 13 2015 21:39
@Susurrus19 @SansPulp u need to use apply if u wanna passs an array as argument to Math.min
KWells
@Susurrus19
Aug 13 2015 21:40
Yeah, the reduce method also doesn't take a variable as input. It is only appended to an actual array object (i.e. [1, 2, 3]).
@moigithub Right. I was just reading that.
@SansPulp This will get you there: Math.max.apply(null, arr);
Works on Math.min as well.
Anthony MacMahon
@SansPulp
Aug 13 2015 21:44
@Susurrus19 @moigithub But if I use Math.max.apply(null, arr);, and push that result to a new variable, then use that variable to start my for loop, and continue to push that to var range, I still can't use that range variable in the reduce method?
KWells
@Susurrus19
Aug 13 2015 21:45
As far as I can tell yes. That is the part I am trying to deduce at the moment.
This message was deleted
Moisés Man
@moigithub
Aug 13 2015 21:45
reduce its an Array method so itshould work...
KWells
@Susurrus19
Aug 13 2015 21:46
The above is returning 5 for arr = [1, 4] not the expected 10.
Moisés Man
@moigithub
Aug 13 2015 21:47
from [1,4] it should push to ur array//generate... [1,2,3,4]
KWells
@Susurrus19
Aug 13 2015 21:47
If you use[1, 2, 3, 4].reduce(function(a, b) { return a + b; }); it works
Moisés Man
@moigithub
Aug 13 2015 21:47
that will only return 5,,, (1+4)
KWells
@Susurrus19
Aug 13 2015 21:49
I corrected that, you're right.
I think I was reading the reduce method instructions incorrectly.
Anthony MacMahon
@SansPulp
Aug 13 2015 21:50
Do you know why the following code is returning [null,null,null,4]
function sumAll(arr) {


  var range = [];
  var max = 0;

  function getMaxOfArray(numArray) {
  return Math.max.apply(null, arr);
  }
  var max = getMaxOfArray;

  if (max == arr[1]) {
    for (i=arr[0]; i<arr[1]; i++) {
      range.push(arr[i]);
    }  
  }
    else {
      for (i=arr[1]; i>0; i--) {
        range.push(arr[i]);
      }
    }

  return range;