These are chat archives for FreeCodeCamp/Help

1st
Aug 2015
secretofmana
@secretofmana
Aug 01 2015 00:03
@gazzer82 its a range 1,2,3,4,5
Feners4
@Feners4
Aug 01 2015 00:04
can someone help with displaying my twitch api query results:
http://codepen.io/Feners4/pen/EjONEe
MatiKid
@MatiKid
Aug 01 2015 00:05
@luishendrix92 I just used if(bool === true || bool === false)
but it’ll be interesting to know why your method isn’t working
Isaac Calvo
@Icalvo1
Aug 01 2015 00:09
returns as an error when anything other than null is used
when I do boo(true) get undefined error
ya idk... did var t = Boolean; boo(t) still returns false
Sergey Zhidkov
@sergey-zhidkov
Aug 01 2015 00:17
@luishendrix92 typeof returns String
Luis Felipe López G.
@luishendrix92
Aug 01 2015 00:19
@sergey-zhidkov Hey thanks, I had forgot about that, now it worked.
function boo(bool) {
  // What is the new fad diet for ghost developers? The Boolean.
  if(typeof bool === "boolean") {
    return true;
  } else {
    return false;
  }
}

boo(null);
MatiKid
@MatiKid
Aug 01 2015 00:22
good to know!
Jeff Bynum
@bynumjj
Aug 01 2015 00:35
Screen Shot 2015-07-31 at 5.29.36 PM.png
AaronOoooo
@AaronOoooo
Aug 01 2015 00:39

'''var friends = new Object();
friends.bill = new Object();
friends.steve = new Object();
friends.aaron = new Object();

friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "(206) 555-5555",
address: ["123 Forest Avenue", "Redmond", "WA", "98052"]
},

steve: {
    firstName: "Steve",
    lastName: "Harvey",
    number: "(334) 555-5555",
    address: ["355 E. Carson way", "Omaha", "Nebraska", "77438"]        
},

aaron: {
    firstName: "Aaron",
    lastName: "Hall",
    number: "(312) 734-0334",
    address: ["3408 Windy Knoll Dr", "Lexington", "KY", "40508"]
}

}

var list = function(obj) {
for (var key in obj) {
console.log(key);
}
}

list(friends);

Did I do that correctly? I was hoping to get some help as to why this prints out twice.
lorenzopieri
@lorenzopieri
Aug 01 2015 00:42
Hello guys! Anyone that has done "Make a person" bonfire can help me with this test?
expect(bob.getLastName()).to.eql('Trees');expected undefined to deeply equal 'Trees'
No one at all? XD
Jeff Bynum
@bynumjj
Aug 01 2015 00:45
This message was deleted
hakimnasir
@hakimnasir
Aug 01 2015 00:50
anyone here has good photoshop skills?
Sergey Zhidkov
@sergey-zhidkov
Aug 01 2015 00:50
@lorenzopieri you should return last name from 'getLastName()' method, but obviously it returns 'undefined'. You need to check your method
lorenzopieri
@lorenzopieri
Aug 01 2015 00:52

Hey @sergey-zhidkov

This is what I wrote and it passes all test cases but that one!

var Person = function(firstAndLast) {
  var firstName = firstAndLast.split(' ')[0] || "";
  var lastName = firstAndLast.split(' ')[1] || "";
  var nameSurname = firstAndLast;

  this.setFirstName = function(fN){
    fN = fN.split(' ');
    firstName = fN[0];
  };

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

  this.setLastName = function(lN){
    lN = lN.split(' ');
    lastName = lN[1];
  };

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

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

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

var bob = new Person('Bob Ross');
bob.getFirstName();
//bob.getFullName();
Sergey Zhidkov
@sergey-zhidkov
Aug 01 2015 00:55
method is looking good, I think problem with 'lastName' variable
or this is an error in tests
lorenzopieri
@lorenzopieri
Aug 01 2015 00:59
Did you pass all tests?
Sergey Zhidkov
@sergey-zhidkov
Aug 01 2015 00:59
yes
lorenzopieri
@lorenzopieri
Aug 01 2015 00:59
If yes, can I see your code?
Sergey Zhidkov
@sergey-zhidkov
Aug 01 2015 01:06

no) my code is shame

this.setLastName = function(lN){
    lN = lN.split(' ');
    lastName = lN[1];
  };

this is your error, you expect only the second name here, not firsAndLast

Theresa Hoang
@Teehoang
Aug 01 2015 01:11
Hi, is anyone working on the Bonfire Reverse A String?
Juan Martínez
@jbmartinez
Aug 01 2015 01:21
@Teehoang I'm not working on that, but I could help
Theresa Hoang
@Teehoang
Aug 01 2015 01:22
i would really appreciate that! i've been googling but nothing is working
am i working in javascript?
Juan Martínez
@jbmartinez
Aug 01 2015 01:23
yes, that bonfire is in javascript
Theresa Hoang
@Teehoang
Aug 01 2015 01:23
i asked earlier and i was advised to use split to convert the string into an array. reverse it and then convert back into a string
secretofmana
@secretofmana
Aug 01 2015 01:23
@Teehoang that sounds right
Juan Martínez
@jbmartinez
Aug 01 2015 01:23
that's the most straightforward way
Theresa Hoang
@Teehoang
Aug 01 2015 01:24
i guess im confused about the format. is everything supposed to be inside the function about the return str?
Juan Martínez
@jbmartinez
Aug 01 2015 01:24
yes
you should put all your code inside the function, at least for this bonfire
in advanced bonfires you may use more than a function
Theresa Hoang
@Teehoang
Aug 01 2015 01:26
how do i use split to convert string into array? i tried str.split(); arr.reverse.join();
Juan Martínez
@jbmartinez
Aug 01 2015 01:27
there are several ways...
in javascript, you can chain function results: str.split().reverse()
Feners4
@Feners4
Aug 01 2015 01:27
any help with using jade html?
Juan Martínez
@jbmartinez
Aug 01 2015 01:28
notice there is a dot, not a semicolon, after split()
beware of the parameter used for split()
@Feners4 I've used jade for some ziplines, but I'm not an expert
Feners4
@Feners4
Aug 01 2015 01:29
@jbmartinez I'm having trouble displaying my twitch api data..
Juan Martínez
@jbmartinez
Aug 01 2015 01:30
@Feners4 I also used angular, jade and sass for that bonfire :smile:
Feners4
@Feners4
Aug 01 2015 01:32
@jbmartinez I'm lost with how to display my data..
Juan Martínez
@jbmartinez
Aug 01 2015 01:34
@Feners4 I'm not sure about your data format, are you putting all in an array?
if so, you can use ng-repeat directive
Feners4
@Feners4
Aug 01 2015 01:34
yeah, im getting arrays..
Juan Martínez
@jbmartinez
Aug 01 2015 01:35
ng-repeat is like for in in javascript
ng-repeat="element in array"
Feners4
@Feners4
Aug 01 2015 01:36
@jbmartinez ohhh
Juan Martínez
@jbmartinez
Aug 01 2015 01:36
then you can use element as any other variable in the scope
Feners4
@Feners4
Aug 01 2015 01:37
@jbmartinez i see, how can I display with jade though?
Juan Martínez
@jbmartinez
Aug 01 2015 01:39
.somediv(ng-repeat="element in array")
  li {{element.name}}
Feners4
@Feners4
Aug 01 2015 01:39
how would i $("wheretodisplay").???(mydata)
@jbmartinez oohhh
Juan Martínez
@jbmartinez
Aug 01 2015 01:40
array should be a variable in the scope (I would use a different variable name, by the way)
and element should be an object containing a name property
so, array is an array of objects in my example, I guess you're getting something similar from the twitch API
Feners4
@Feners4
Aug 01 2015 01:43
yeah
Juan Martínez
@jbmartinez
Aug 01 2015 01:45
@Teehoang How's your bonfire?
Franco Zapata
@Francozt01
Aug 01 2015 01:55
can someone tell me the answer to the "palindrome bonfire"
Joris Labie
@labiej
Aug 01 2015 01:56
It's better to guide you
Franco Zapata
@Francozt01
Aug 01 2015 01:58

function palindrome(str) {
// Good luck
var str1 = str.replace(/[\w\s]+/g).toLowerCase();
return str1 === str1.split(" ").reverse().join(" ");
}

palindrome("eye");

returns 5/7 as correct,
Joris Labie
@labiej
Aug 01 2015 02:00
replace takes 2 arguments. You first remove spaces and other stuff, then you spilt on spaces
try to remove the space in split and join
Franco Zapata
@Francozt01
Aug 01 2015 02:01
still the same
Joris Labie
@labiej
Aug 01 2015 02:02
replace needs a second argument
you catch all 'characters' that aren't in the alphabet and aren't a number but the replacement is undefined
try console.log("ab cd&de".replace(/[\W\s]+/g)) to see it
Franco Zapata
@Francozt01
Aug 01 2015 02:04
@labiej thanks for you help
Theresa Hoang
@Teehoang
Aug 01 2015 02:05
@jbmartinez i finally figured it out! i was overthinking/overcomplicating the code. thanks :)
Joris Labie
@labiej
Aug 01 2015 02:05
Don't forget to carefully read the MDN documentation
Juan Martínez
@jbmartinez
Aug 01 2015 02:05
@Francozt01 @labiej you're using \w instead of \W, so you're replacing actual words
@Teehoang good! :thumbsup:
Franco Zapata
@Francozt01
Aug 01 2015 02:06
@labiej @jbmartinez i did it..
Joris Labie
@labiej
Aug 01 2015 02:06
During the course we can help you. Once you do real projects you want to be able to use the docs
Franco Zapata
@Francozt01
Aug 01 2015 02:06

function palindrome(str) {
// Good luck

var str1= str.replace(/[^A-Za-z]+/g,'').toLowerCase();
return str1 === str1.split('').reverse().join('');
}

palindrome("eye");

Joris Labie
@labiej
Aug 01 2015 02:06
Shorter is if you replace ^A-Za-z with \W
Franco Zapata
@Francozt01
Aug 01 2015 02:07
i did the Regex lessons yesterday
Joris Labie
@labiej
Aug 01 2015 02:07
Kudos for using them though. They will always remain tricky
Franco Zapata
@Francozt01
Aug 01 2015 02:08
with the time its going to be easy to recognize which one i have to use
Joris Labie
@labiej
Aug 01 2015 02:08
In simple applications I agree
But regex's are incredibly versatile
Franco Zapata
@Francozt01
Aug 01 2015 02:09
CodeSchool published a new Free Course of Regex
i did the CodeSchool + the FCC regex courses
Joris Labie
@labiej
Aug 01 2015 02:09
Nice
Franco Zapata
@Francozt01
Aug 01 2015 02:10
also i have 2 other pages to practice more regex
Joris Labie
@labiej
Aug 01 2015 02:10
If I'm not mistaken this http://regex.learncodethehardway.org/book/ will be one of the best courses you can follow
gazzer82
@gazzer82
Aug 01 2015 02:10
Ok so just completed the Smallest Common Multiple bonfire, but it's take me hours and it's a lot of code. Could someone take a look and let me know what you think. Maybe suggest a better/more efficient way of doing it?
Joris Labie
@labiej
Aug 01 2015 02:10
@gazzer82 Sure
Franco Zapata
@Francozt01
Aug 01 2015 02:11
@labiej thanks for your help
gazzer82
@gazzer82
Aug 01 2015 02:11
@labiej
Joris Labie
@labiej
Aug 01 2015 02:11
@Francozt01 keep up the good work
Franco Zapata
@Francozt01
Aug 01 2015 02:11
@labiej i will ! :D
gazzer82
@gazzer82
Aug 01 2015 02:11
function smallestCommons(arr) {
    var sortedArr = arr.sort();
    var numbersArr = createNewArray(sortedArr[0],sortedArr[1]);
    var factorsArr = [];
    var returnFactors = [];
    for(var m=0;m<numbersArr.length;m++){
      factorsArr.push(calculateFactors(numbersArr[m]));
    }
    for(var i=0;i<sortedArr[1];i++){
        var count = 0;
        for(var j=0;j<factorsArr.length;j++){
            if(factorsArr[j][i+1] > count){
                    count = factorsArr[j][i+1];
                }
        }
        for(var k=1;k<=count;k++){
            returnFactors.push(i+1);
        }
    }
    return returnFactors.reduce(function(previous, current){
        return previous*current;
    });
}


function calculateFactors(num){
    var primes = {};
    var primesArray = [];
    var tempNum = num;
    while(tempNum%2 === 0 && tempNum >= 1){
        tempNum = tempNum/2;
        if(!primes.hasOwnProperty('2')){
            primes['2'] = 0;
        }
        primes['2'] ++;
        primesArray.push(2);
    }
    for(var i=3;i<tempNum;i+=2){
        while(tempNum%i === 0){
            if(!primes.hasOwnProperty(i)){
                primes[i] = 0;
            }
            primes[i] ++;
            primesArray.push(i);
            tempNum = tempNum/i;
        }
    }
    if(tempNum>2){
        if(!primes.hasOwnProperty(tempNum)){
                primes[tempNum] = 0;
            }
            primes[tempNum] ++;
            primesArray.push(tempNum);
    }
    return primes;
}

function createNewArray (startNum, endNum){
    return Array.apply(0,new Array((endNum+1)-startNum)).map(function(element, index){
        return index+startNum;
    });
}
Joris Labie
@labiej
Aug 01 2015 02:12
It is long indeed
gazzer82
@gazzer82
Aug 01 2015 02:12
@labiej Thanks, be gentle ;)
Joris Labie
@labiej
Aug 01 2015 02:12
I'll give some hints
First, I call the least common multiple of a and b lcm(a, b)
Second lcm(a, b, c) = lcm(a, lcm(b, c)
The last point introduces a recursion relation
If we call the greatest common divisor of a and b gcd(a, b)
then we can write lcm(a, b) = a*b/gcd(a, b)
You understand what I'm getting at?
gazzer82
@gazzer82
Aug 01 2015 02:18
Yes i think so, i think my brains a little broken after getting that to work, so i'll copy this down and revisit tomorrow.
Thanks for the feedback!
Joris Labie
@labiej
Aug 01 2015 02:19
Thanks for asking, it made me look back and apparently my own solution can be improved as well
gazzer82
@gazzer82
Aug 01 2015 02:20
If you didn't mind sharing your solution, it would be really helpful to look through a different completed version?
Joris Labie
@labiej
Aug 01 2015 02:20
function gcd(a,b){
  var min;

  if(a>b)
    min = b;
  else
    min = a;

  while(min>=1){
    if( a%min === 0 && b%min === 0 )
      break;
    min--;
  }

  return min;
}

function lcm(a,b){
  return ( a * b )/gcd(a,b);
}

function smallestCommons(arr) {
  var lower, upper;
  var lcmOut = 0;
  if( arr[0]>arr[1]){
    upper = arr[0];
    lower = arr[1];
  }else{
    upper = arr[1];
    lower = arr[0];
  }


  lcmOut = lcm(upper-1, upper);
  upper = upper - 2;

  while(upper >= lower){
    lcmOut = lcm(upper, lcmOut);
    upper--;
  }

  return lcmOut;
}


smallestCommons([1,5]);
SojournerOctocat
@SojournerOctocat
Aug 01 2015 02:21

Working on Roman Numeral Converter Bonfire. Here's what I have so far:

function convert(num) {
    var romanNumber = "";
    var value = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
    var roman = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'];

        while (num > 0) {
            console.log("value: " + value[iterator]);
            if (num > value[iterator]) {
                romanNumber = romanNumber + roman[iterator];
                console.log("roman numeral: " + romanNumber);

                num = num - value[iterator];
                console.log("num: " + num);
            }
        }

    return romanNumber;
}

convert(36);

But I don't know how to loop through the numbers in the value array. I was using a for loop before, but it only caused the code to loop endlessly. Any hints?

gazzer82
@gazzer82
Aug 01 2015 02:22
Really helpful, thanks!
Joris Labie
@labiej
Aug 01 2015 02:23
@gazzer82 remember in a few weeks(tops) you'll make stuff like this keep improving/honing your skills by asking for critiques
Nicholas Gibson
@promethi0s
Aug 01 2015 02:24
@labiej I dig your loading graphic. I should probably add that... mine just copied the target identically
Rex Schrader
@SaintPeter
Aug 01 2015 02:25
@SojournerOctocat You need to increment your iterator and you need to set an initial value for it as well.
@SojournerOctocat You can just do iterator++; at the end of your while loop
Elliescode
@EllieAdam
Aug 01 2015 02:28
Evening Campers!
SojournerOctocat
@SojournerOctocat
Aug 01 2015 02:28
@SaintPeter That's the thing. I can't just increment the iterator because then it will just go to the next number in the value array and sometimes I have to repeat a value. For instance, 36 needs three XXX's.
Rex Schrader
@SaintPeter
Aug 01 2015 02:30
@SojournerOctocat Well, could do some sort of test to determine if it was "time" to increment? What condition would need to be true for you to increment?
SojournerOctocat
@SojournerOctocat
Aug 01 2015 02:32
@SaintPeter num would have to be less than value[iterator].
mkjgry
@mkjgry
Aug 01 2015 02:33
hello
Rex Schrader
@SaintPeter
Aug 01 2015 02:33
@SojournerOctocat Ok . . . that sounds like an if statement to me :D
SojournerOctocat
@SojournerOctocat
Aug 01 2015 02:37
@Saint Oh. I used a while statement and it looped endlessly. Will try an if statement.
Rex Schrader
@SaintPeter
Aug 01 2015 02:37
@SojournerOctocat Well, you use both
@SojournerOctocat Keep your while loop, but only increment your iterator when your if statement is true
SojournerOctocat
@SojournerOctocat
Aug 01 2015 02:37
I nested another while statement in my while statement.
Rex Schrader
@SaintPeter
Aug 01 2015 02:38
@SojournerOctocat That works too :D
SojournerOctocat
@SojournerOctocat
Aug 01 2015 02:38
@SaintPeter No. It didn't.
It just looped endlessly.
Rex Schrader
@SaintPeter
Aug 01 2015 02:38
D'oh
Well, try an if statement - you want to increment only when your condition is true - the one you listed above.
Chad Kreutzer
@ChadKreutzer
Aug 01 2015 02:40
I'm making a person and this looks to me like it should work. And it does for all the tests but one: on the first one it says: expect(Object.keys(bob).length).to.eql(6);expected 3 to deeply equal 6
var Person = function (name) {
    this.firstAndLast = name;
    var temp = [];
    temp = name.match(/^\w+/);
    this.first = temp[0];
    temp = name.match(/\w+$/);
    this.last = temp[0];
};
Person.prototype.setFullName = function (firstAndLast) {
    this.firstAndLast = firstAndLast;
};
Person.prototype.getFullName = function () {
    return this.firstAndLast;
};
Person.prototype.setFirstName = function (first) {
    this.first = first;
    this.firstAndLast = this.firstAndLast.replace(/^\w+/, first);
};
Person.prototype.getFirstName = function () {
    return this.first;
};
Person.prototype.setLastName = function (last) {
    this.last = last;
    this.firstAndLast = this.firstAndLast.replace(/\w+$/, last);
};
Person.prototype.getLastName = function () {
    return this.last;
};
Rex Schrader
@SaintPeter
Aug 01 2015 02:43
@ChadKreutzer They're expecting you to define your functions inside the object definition, not as prototypes. Even though that's probably the "right" way to do things, they want you to do them as this.setFullName = function(firstAndLast) { /* ... */ }
@ChadKreutzer And you won't be able to do this.firstAndLast - you need to use private variables.
SojournerOctocat
@SojournerOctocat
Aug 01 2015 02:44
Working on Bonfire Roman Numeral Converter and my code is looping endlessly. Can anyone explain why?
function convert(num) {
    var romanNumber = "";
    var iterator = 0;
    var value = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
    var roman = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'];

        while (num > 0) {
                console.log("value: " + value[iterator]);
                if (num > value[iterator]) {
                    romanNumber = romanNumber + roman[iterator];
                    console.log("roman numeral: " + romanNumber);

                    num = num - value[iterator];
                    console.log("num: " + num);
                } else {
                    iterator++;
                }
            }


    return romanNumber;
}

convert(36);
Chad Kreutzer
@ChadKreutzer
Aug 01 2015 02:46
lol. so I did it the "right" way. They just want it all inside the person definition. like C++?
Rex Schrader
@SaintPeter
Aug 01 2015 02:46
@SojournerOctocat Humm, it looks like you also need to make sure that value[iterator] is defined
@ChadKreutzer Yeah, which you'll learn later is "the wrong way", but for the purposes of this exercise . . .
E-Tank
@E-Tank
Aug 01 2015 02:46
Running through the earlier Java script stuff and having an issue. It says I've got an unexpected token { but I can't find it.
var userChoice = prompt("Do you choose Rock, Paper, or Scissors?");
var computerChoice = Math.random();
if (computerChoice <= 0.33) {
 computerChoice = "Rock";
}
else if (computerChoice > 0.34 && computerChoice < 0.66) {
    computerChoice = "Paper";
}
else (computerChoice >= 0.67) {
 computerChoice = "Scissors";
}
console.log(computerChoice);
SojournerOctocat
@SojournerOctocat
Aug 01 2015 02:47
@SaintPeter What do you mean?
Rex Schrader
@SaintPeter
Aug 01 2015 02:47
@SojournerOctocat For some reason your itterator is going beyond the end of the value array.
Chad Kreutzer
@ChadKreutzer
Aug 01 2015 02:48
@SaintPeter What's funny is, I'm actually doing it they way the Udacity course that the OOP waypoints from Free Code Camp linked to said to do it.
Rex Schrader
@SaintPeter
Aug 01 2015 02:48
@SojournerOctocat http://repl.it/zgR/1

@E-Tank You're missing an if here:

else (computerChoice >= 0.67) {

I suggest using http://repl.it to help debug your code.

E-Tank
@E-Tank
Aug 01 2015 02:50
Ah, alright.
Chad Kreutzer
@ChadKreutzer
Aug 01 2015 03:03
Thank you, @SaintPeter . On to mapping the debris.
Rex Schrader
@SaintPeter
Aug 01 2015 03:03
@ChadKreutzer :D Good luck!
Chad Kreutzer
@ChadKreutzer
Aug 01 2015 03:03
@SaintPeter Thanks.
SojournerOctocat
@SojournerOctocat
Aug 01 2015 03:08
@SaintPeter That worked. Thanks!
George
@sushiyea
Aug 01 2015 03:09
oh ok I need help with HTML waypoint #19
Rex Schrader
@SaintPeter
Aug 01 2015 03:09
@SojournerOctocat Awesome! I used almost that identical logic to solve mine. It's a nice general solution.
@sushiyea Lay it on me :D
George
@sushiyea
Aug 01 2015 03:10
<style>
.smaller-image {
width: 100px;
}
</style>
I have it inputed after H2 class cline
line
or was i supposed to declare .smaller-image class ?
Rex Schrader
@SaintPeter
Aug 01 2015 03:11
@sushiyea Ok, so you've got your class definition - you could actually just put the .smaller-image stuff inside the other style tag. Now you need to apply the smaller-image class to the img tag.
George
@sushiyea
Aug 01 2015 03:14
inside of the img src tag ?
Alanna M
@weirdhockeygirl16
Aug 01 2015 03:15
in the class
of the image
Rex Schrader
@SaintPeter
Aug 01 2015 03:15

@sushiyea No. You've got your img tag:

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

And you need to add a "class" attribute to it. Look at the <h2> element right above it

@sushiyea

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

See how it has a class='blahblah'? You need to do that for the img tag, but with your .smaller-image class

George
@sushiyea
Aug 01 2015 03:18
<img class='smaller-image'></img>
Rex Schrader
@SaintPeter
Aug 01 2015 03:18
@sushiyea Yes . . . but you can't REMOVE the src attribute. You're adding things, not taking them away
George
@sushiyea
Aug 01 2015 03:19
ok, got it , thanks
Rex Schrader
@SaintPeter
Aug 01 2015 03:20
@sushiyea Awesome!
Abdul R. Taleb-Agha
@atalebagha
Aug 01 2015 03:21
Hi all I’m on Bonfire: Convert HTML Entities. Can someone tell me if I’m on the right track?
function convert(str) {
  // &colon;&rpar;
  var rep = function (match, p1, offset, string) {
  return list[match];
  };
  var list = {
    "\"" : "&quot", 
    "'"    : "&apos",
    "&"    : "&amp",
    "<"    : "&lt",
    ">"    : "&gt"
  };
  str.replace(/(["'<>])/g, rep);
  return str;
}
Rex Schrader
@SaintPeter
Aug 01 2015 03:24
@atalebagha Very close. Couple things: 1) HTML Entities end with a semicolon. 2) Your Regexp will certainly identify items, but you need to choose the right one to replace it with.
Robert
@rc242
Aug 01 2015 03:34
heyo.
Rex Schrader
@SaintPeter
Aug 01 2015 03:36
Yo yo yo
Chad Kreutzer
@ChadKreutzer
Aug 01 2015 03:51
Wow. That was easy. Pairwise looks intimidating, though.
NicoleSewell
@NicoleSewell
Aug 01 2015 04:00
so I am on the lesson css selectors to style elements and I am stuck.This is what I am typing<style>h2{color:blue;}</style>. It keeps telling me your h2 element needs to be blue. What am I doing wrong
Rex Schrader
@SaintPeter
Aug 01 2015 04:06
@NicoleSewell That looks right. Where are you putting it?
L. Becker
@LCBecker
Aug 01 2015 04:11
I'm getting a weird error when I try to tweet my quote for the Quotation Generator zipline. My console says, "Refused to display [twitter url] in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'." Anyone know how to fix that?
Rex Schrader
@SaintPeter
Aug 01 2015 04:13
@LCBecker Maybe - are you using AJAX to submit the tweet? Because I don't think that'll work. There is a method of submitting a tweet in a URL form.
@LCBecker Look at the "tweet" intent here: https://dev.twitter.com/web/intents
Just provide the user with a clickable link.
L. Becker
@LCBecker
Aug 01 2015 04:18
@SaintPeter I am using intent
It doesn't work
NicoleSewell
@NicoleSewell
Aug 01 2015 04:19
@SaintPeter the first line
Rex Schrader
@SaintPeter
Aug 01 2015 04:20
@LCBecker for your anchor tag, try this attribute: <a target="_blank" href="...">
L. Becker
@LCBecker
Aug 01 2015 04:20
Wow! NICE!
Rex Schrader
@SaintPeter
Aug 01 2015 04:20
@LCBecker That'll open it in a new window :D
L. Becker
@LCBecker
Aug 01 2015 04:21
Awesome!! I'm so happy! I've been working on this all day!
Rex Schrader
@SaintPeter
Aug 01 2015 04:21
@NicoleSewell What specific waypoint are you on? I need to look it up.
L. Becker
@LCBecker
Aug 01 2015 04:21
Thank you so much! bows to Saint Peter
Rex Schrader
@SaintPeter
Aug 01 2015 04:22
@LCBecker That looks nice pretty nice. I got some fun quotes out of it, too.
@NicoleSewell Did you see this: "Remove the style attribute from your h2 element."
@NicoleSewell If you don't remove the style attribute then the <style> tag can't override it.
Kolloom
@Kolloom
Aug 01 2015 04:35
is endslice in str.slice() include in the output?
Kolloom
@Kolloom
Aug 01 2015 04:41
nevermind, its excluded
console.log("Hello".slice(0, 4)) // outputs "Hell";
Aniruddh Agarwal
@anrddh
Aug 01 2015 04:56
The semi colon should come before the comment starts :P
Kolloom
@Kolloom
Aug 01 2015 05:05
@awesomeaniruddh indeed, but repl.it doesn't seems to care at all.
it doesn't effect the output at this case, so whatever...
Benjamin
@b1ggb3n86
Aug 01 2015 05:19
any body have any advice for the Title Case bonfire?

function titleCase(str) {
str = str.toLowerCase();
var splitStr = str.split(' ');
var splitLength = splitStr.length;

for (i = 0; i < splitLength; i++) {
splitStr[i].charAt(0).toUpperCase();
}
str = splitStr.join(' ');
return str;
}

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

SojournerOctocat
@SojournerOctocat
Aug 01 2015 05:31
@b1ggb3n86
function titleCase(str) {
  newArr = str.split(" ")
  for (var i = 0; i < newArr.length; i++) {
    newArr[i] = newArr[i].charAt(0).toUpperCase() + newArr[i].slice(1, newArr[i].length).toLowerCase();
  }




  newArr = newArr.join(" ");

  return newArr;
}
Benjamin
@b1ggb3n86
Aug 01 2015 05:33
thanks @SojournerOctocat , I don't really remember slice too much. but i can see how it can be helpful
dc
@dcsan
Aug 01 2015 05:34

announcement

Hay All! We're working on a new CamperBot for FreeCodeCamp. This will make the chat rooms more fun and useful. We're launching soon, but if you have time a bit tonite please help us betatest and get some feedback.

http://bot.freecodecamp.com/go?room=camperbot/testing&topic=betatesting

Type help to get started with basic commands

SojournerOctocat
@SojournerOctocat
Aug 01 2015 05:40
Working on Search and Replace Bonfire. The ignore case flag isn't working as I thought it would. The code below doesn't ignore case. How do I fix that?
function replace(str, before, after) {
    console.log(str.replace(before, after, "i"));
}

replace("A quick brown fox jumped over the lazy dog", "Jumped", "leaped");
David Taylor
@cornjacket
Aug 01 2015 05:48
hi everyone
secretofmana
@secretofmana
Aug 01 2015 05:53
hi
Rex Schrader
@SaintPeter
Aug 01 2015 06:17
@SojournerOctocat str.replace returns a string, it doesn't alter the existing string. You have to assign it to a variable. Also, you have to return that string . . .
Juan David Pastas
@juanpastas
Aug 01 2015 06:32
hi, I am getting unexpected token ILLEGAL here https://gist.github.com/juanpastas/5e694465eb624f0b9fde
but when I run that on node console I don't get any error
Juan David Pastas
@juanpastas
Aug 01 2015 06:37
how should it be?
Abdul R. Taleb-Agha
@atalebagha
Aug 01 2015 06:37
thanks @SaintPeter I got all tests passing except the apostrophe
function convert(str) {
  // &colon;&rpar;
  var rep = function (match) {
    var list = {
      '"'   : "&quot;", 
      "'"    : "&apos;",
      "&"    : "&amp;",
      "<"    : "&lt;",
      ">"    : "&gt;"
    };
    return list[match];
  };

  str = str.replace(/["'<>]/g, rep);
  return str;
}
Juan David Pastas
@juanpastas
Aug 01 2015 06:37
@secretofmana
Luis Felipe López G.
@luishendrix92
Aug 01 2015 06:39
@atalebagha Try &rsquo or &#8217
secretofmana
@secretofmana
Aug 01 2015 06:39
@juanpastas the if statement ends at the semi colon, but then you start a else
Juan David Pastas
@juanpastas
Aug 01 2015 06:40
I tried wrapping on {}
and no luck either
secretofmana
@secretofmana
Aug 01 2015 06:40
where are you running it that gives an error?
Juan David Pastas
@juanpastas
Aug 01 2015 06:41
on freecodecamp interface
on jsbin it works
Woolwit
@Woolwit
Aug 01 2015 06:42
Working on Bonfire Numbers in Range (wishing for Python) but this is a more general question. A lot of the Mozilla JS docs seem to have examples similar to this... where I'm looking to return the LAST return of the function and so keep failing tests because the function is returning each iteration, if that makes sense. How do I only return the final return previousValue + currentValue; ?
[0, 1, 2, 3, 4].reduce(function(previousValue, currentValue, index, array) {
  return previousValue + currentValue;
});
secretofmana
@secretofmana
Aug 01 2015 06:43
@juanpastas it should mention where it occurs
the error
Juan David Pastas
@juanpastas
Aug 01 2015 06:43
It does not, unfortunately
I thought it was because I was editing text on sublime and I had some tabs
but I changed them and it did not work either
Gavin
@gavin76
Aug 01 2015 06:48
@atalebagha Hi, I noticed you're missing something in your regex
Juan David Pastas
@juanpastas
Aug 01 2015 06:56
@Woolwit it should return the last... hmmm, what is the last? can you explain with example?
secretofmana
@secretofmana
Aug 01 2015 06:57
@juanpastas ok i figured it out
and L21
they are being read in as // comments
but since they're not, it mangles those 2 lines, and it causes errors when it gets evaluated, so if it just replace the ///////
it should work
Bianca Mihai
@biancamihai
Aug 01 2015 07:00
@Woolwit what do you want to do?
Woolwit
@Woolwit
Aug 01 2015 07:01
@juanpastas I'm probably confused... but it seemed that when I was running the .reduce on my array .reduce was returning first 1 then 3 then 6 and then finally 10. And perhaps I'm confused but in the Bonfire it seemed like the very first return, 1 was terminating the function.
Juan David Pastas
@juanpastas
Aug 01 2015 07:01
@secretofmana thanks a lot, it was that and removing the c(x) at the end
secretofmana
@secretofmana
Aug 01 2015 07:02
ok i saw your issue, i commented on it haha, not sure if you want to go forward with it or not
but it's a bug, but outside of FCC code though i believe
it's part of their courseware js library they are using, i'm not sure if they wrote it themselves or not
Woolwit
@Woolwit
Aug 01 2015 07:03
@juanpastas I'm probably too confused to give you a decent question. I solved the Bonfire but it's not pretty.
Juan David Pastas
@juanpastas
Aug 01 2015 07:04
@Woolwit do you want to improve what you have? or is it a different question?
Bianca Mihai
@biancamihai
Aug 01 2015 07:04
@Woolwit perhaps this will help you with reduce https://www.airpair.com/javascript/javascript-array-reduce
Juan David Pastas
@juanpastas
Aug 01 2015 07:05
reduce is not easy to use in that exercise
Juan David Pastas
@juanpastas
Aug 01 2015 07:05
is easier a for loop
secretofmana
@secretofmana
Aug 01 2015 07:05
@juanpastas basically they just have a quick and sloppy way of removing comments from peoples code they submit
Woolwit
@Woolwit
Aug 01 2015 07:06
I think I'm going to call it a night. But it would be great if at the end of all the Bonfires I could see the 'best' way to solve them. Thanks for asking @juanpastas
Gavin
@gavin76
Aug 01 2015 07:06
Hi, would anyone be able to see what I got wrong in Bonfire: Sum All Odd Fibonacci Numbers? They all work apart from sumFibs(75024). Here's the code:
function sumFibs(num) {
  var num1 = 1,
      num2 = 1,
      sum,
      sumOdd = 2;

  console.log(num1,num2,sumOdd);

  while ( num >= sumOdd ) {
    sum = num1 + num2;
    num1 = num2;
    num2 = sum;

    if ( num2 % 2 !== 0) {
      sumOdd += num2;
      console.log('num: '+ num +'  sumOdd: '+sumOdd);
    }
    console.log(num1,num2,sum,sumOdd);

  }
  return sumOdd;
}

sumFibs(4);
sumFibs(75024);
Thanks
Juan David Pastas
@juanpastas
Aug 01 2015 07:07
@Woolwit
function sumAll(arr) {
  var s = 0,
      i = Math.min(arr[0], arr[1]),
      e = Math.max(arr[0], arr[1]);
  for(var j = i; j <= e; j++) s+=j;
  return s;
}
secretofmana
@secretofmana
Aug 01 2015 07:08
@juanpastas it's a easy fix, if you want to get some contributions to the FCC code, i just don't know if that code belongs to them
@juanpastas i suggest you do it anyway since it's a small easy fix, and it has the possibility of getting you a commit into FCC
Woolwit
@Woolwit
Aug 01 2015 07:09
@juanpastas Wow! Check out this mess! Will study yours... tomorrow.
function sumAll(arr) {
  var arr2 = [];
  var arr3 = [];
  var arr4 = [];

   if (arr[0] > arr[1]) {
    arr2.push(arr[1]);
    arr2.push(arr[0]);
    for (var i = arr2[0]; i <= arr2[1]; i++) {
      arr3.push(i);
    }
    var x = arr3[0];
    arr3.reduce(function(previousValue, currentValue, index, array) {
  x = (x + currentValue);
  });
  return x;
  }else{
    for (var j = arr[0]; j <= arr[1]; j++) {
      arr4.push(j);
    }
  var y = arr4[0];
  arr4.reduce(function(previousValue, currentValue, index, array) {
  y = (y + currentValue);
  });
  return y;
  }
}

sumAll([10, 5]);
Juan David Pastas
@juanpastas
Aug 01 2015 07:11
@secretofmana hahaha, does not seem easy for me, but is a good idea to contribute, that RE seems so complex
I would do new RegExp('^\s+//')
but they might have another cases covered
secretofmana
@secretofmana
Aug 01 2015 07:13
right, so you want to do the least impact but fix the bug / improve it so your case isn't a bug anymore
@juanpastas so, the code users input comes in as a giant string, just split it on new lines and run their RegExp as is on every line, and detect if the matched RegExp is appearing within quotes ' or "
the hard part is just detecting if it's wrapped in quotes
Juan David Pastas
@juanpastas
Aug 01 2015 07:15
why detect that?
secretofmana
@secretofmana
Aug 01 2015 07:15
also you would have to separate the / / regex in there
to be on it's own
/* */
@juanpastas because the function or regex is confusing "///" a string as a comment
you're basically just trying to make it smarter to not touch strings with "//" in them as comments
Juan David Pastas
@juanpastas
Aug 01 2015 07:17
this RegExp('^\s+//') would solve that right?
instead of that long RE, right?
secretofmana
@secretofmana
Aug 01 2015 07:17
their regexp also tests for multi line comments /* */
@juanpastas here is a jsbin of the function and all that https://jsbin.com/fayezajihi/edit?js,console
you see it deleteds after and including the first //
even though it's a string
but it thinks it's a comment
Juan David Pastas
@juanpastas
Aug 01 2015 07:20
I solved it in jsbin
secretofmana
@secretofmana
Aug 01 2015 07:20
@juanpastas it's up to you, you might be interested in giving it a crack at it, but you should leave the issue open #1434
since it is a bug
Juan David Pastas
@juanpastas
Aug 01 2015 07:21
I see, can you check again jsbin
I think is solved now
secretofmana
@secretofmana
Aug 01 2015 07:22
can't see, but i am heading to bed anyway, up to you to give it a shot, i'll keep an eye out on the issue to see how it goes if you do, good luck
Juan David Pastas
@juanpastas
Aug 01 2015 07:22
thanks
Filip Karlo Došilović
@fkdosilovic
Aug 01 2015 08:27

// Basic Algorithm Scripting, Bonfire 36
var ret = [];
function rec(arr) {
for(var i = 0; i < arr.length; ++i) {
if(Array.isArray(arr[i]))
rec(arr[i]);
else
ret.push(arr[i]);
}
}

function steamroller(arr) {
rec(arr);
return ret.slice(4, ret.length);
}

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

// Basic Algorithm Scripting, Bonfire 36
var ret = [];
function rec(arr) {
  for(var i = 0; i < arr.length; ++i) {
    if(Array.isArray(arr[i]))
      rec(arr[i]);
    else
      ret.push(arr[i]);
  }
}

function steamroller(arr) {
  rec(arr);
  return ret.slice(4, ret.length);
}

steamroller([1, [2], [3, [[4]]]]);
so i solved bonafire 36, but if i dont have ret.slice(4, ret.length) i get result such as = [1, 2, 3, 4, result i need]
why do i get there 1, 2, 3, 4 at the beginning?
Giorgio Giuliani
@gigiuliani
Aug 01 2015 08:52
blob

function where(collection, source) {
var arr = [];
// What's in a name?
var sourceProp = Object.keys(source); //I find which properties has our object source

for(var i in collection){
if(collection[i].hasOwnProperty(sourceProp) && collection[i][sourceProp]===source[sourceProp])//match property and values
arr.push(collection[i]);
//QUESTION: the parameter of hasOwnProperty is not a string?? I'm entering an array - this is the same also for the value check. I'm missing something?

J. Ellis
@xeno-j
Aug 01 2015 09:06
Hey can anyone help me with Bonfire: Streamroller?

'''
function steamroller(arr) {
// I'm a steamroller, baby
var result = [];
var re = /(\d)/g;
var merged = arr.toString().split(",");
for (var i = 0; i < merged.length; i++) {
if (re.test(merged[i])) {
result.push(parseInt(merged[i]));
} else {
result.push(merged[i]);
}
}
return result;
}

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

result I get is: [1, "2", 3, "4"]
so for whatever reason, 2 and 4 remain strings.
J. Ellis
@xeno-j
Aug 01 2015 09:15
Also how do people post their code properly, with the dark bg, etc?
sawdagar
@heemadri
Aug 01 2015 09:22
I just start learning coding from today with freecodecamp. So still I do not have any query. But soon I'll ask for some help. So, please stay with me.
NikkoNeko
@NikkoNeko
Aug 01 2015 09:30
@xeno-j just add ``` a line before and after your code :)
jordanelizaga
@jordanelizaga
Aug 01 2015 09:33
can someone help me with the pseudocode for inventory update?
I was able to create an array from the two lists that have the same strings, like 'hair pin', and added them up. How do I get the rest of the two lists, i.e. those that are not in both lists
Jakob Dahl
@saadanerdetbare
Aug 01 2015 09:46
@xeno-j write your message, Shift + Enter, 3 backticks `, Shift + Enter, paste code, Shift + Enter, 3 backticks, send with Ctrl + Enter
dht0my
@dht0my
Aug 01 2015 09:56
This message was deleted
This message was deleted
Marie Pelletier
@Marie000
Aug 01 2015 10:34
I am working on Bonfire: Where Art Thou and I do not understand the output that is expected. For the input that is on the screen, it expects [Array(1)] and I am getting [{first: "Romeo", last:"Montague"}]
David Terry
@xwvvvvwx
Aug 01 2015 10:45
@xeno-j you are missing a parseInt in the else statement
J. Ellis
@xeno-j
Aug 01 2015 11:10
@davidterry01 My intention is for the loop to go the else statement if the character contained in the string isn't a number.
evaristoc
@evaristoc
Aug 01 2015 11:18
@Woolwit are you still there?
Can I advise you to check what other people have been recommending to solve that exercise (and any other problem) by going through the Search of the Gitter channel and query for "Sum All Numbers in a Range"? I think that is the problem, isn't it?
I recommend you (all) to check the previous comments by other who have gone through your problem and check... You will be surprise how common your problem is...
The best way is to see as many solutions as possible: there are more than one way to solve the problems, but some are more "adequate", other ones are "cleaner", "other more "efficient". Try to understand as many solutions as possible...
J. Ellis
@xeno-j
Aug 01 2015 11:25

Ok I solved it but I don't get why it worked lol

function steamroller(arr) {
  // I'm a steamroller, baby
  var result = [];
  var merged = arr.toString().split(",");
  for (var i = 0; i < merged.length; i++) {
    if (merged[i] === "") {
      merged.splice(i, 0);
    }
    else if (/(\d)/.test(merged[i])) {
      result.push(parseInt(merged[i]));
    }
    else {
      result.push(merged[i]);
    }
  }
  return result;
}

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

The line:

merged.splice(i, 0);

succeeded in deleting the empty array value, but I don't understand why? Because the second number is zero, doesn't that mean zero values are deleted? Can someone explain?

evaristoc
@evaristoc
Aug 01 2015 11:30
@xeno-j Just by quickly looking at it, I think that the problem is solved because your if condition. The value is not deleted, but the split point (i) breaks at that point. Wait for more inputs (I am not a JS expert myself...)
J. Ellis
@xeno-j
Aug 01 2015 11:34

@evaristoc Yeah I think what happened is it just didn't get added to the result array. When I did

merged.splice(i, 1)

it deleted the empty array but also the value that came after it, which was strange.

evaristoc
@evaristoc
Aug 01 2015 11:37
@xeno-j yes, that's right
is the "else"... I don't know what the exercise is about, sorry...
and because you wrote "if" and then "else if", it is checking that twice, I guess... Maybe you want to try only an "if-cond" with the second statement, (/(\d)/.test(merged[i]))? This could be something to make your code cleaner
I don't know the purpose of the exercise... so I am not sure if this will help...
J. Ellis
@xeno-j
Aug 01 2015 11:42
@evaristoc i did that at first and the empty array was included, so i had to make the additional one to skip over it. it's all good i solved it. :smile:
evaristoc
@evaristoc
Aug 01 2015 11:42
@xeno-j great!
Chad Kreutzer
@ChadKreutzer
Aug 01 2015 11:45
I'm feeling good and comfortable with JavaScript. I'm just concerned that I feel like I've forgotten most of the HTML/CSS lessons on the way.
(Although I still haven't grokked Array.reduce())
evaristoc
@evaristoc
Aug 01 2015 11:50
@xeno-j : some debugging... putting your code at repl.it
function steamroller(arr) {
  // I'm a steamroller, baby
  var result = [];
  var merged = arr.toString().split(",");
  console.log(merged);
  for (var i = 0; i < merged.length; i++) {
    if (merged[i] === "") {
      merged.splice(i, 0);
      console.log("in if-cond", merged, i);
    }
    else if (/(\d)/.test(merged[i])) {
      result.push(parseInt(merged[i]));
      console.log("in else/if-cond", merged, i);
      console.log("result ", result);
    }
    else {
      result.push(merged[i]);
    }
  }
  return result;
}

steamroller([1, [], [3, [[4]]]]);
Shouvik Roy
@royshouvik
Aug 01 2015 11:51
@evaristoc Have you tried Chrome debugger?
evaristoc
@evaristoc
Aug 01 2015 11:52
@royshouvik the problem is not mine, and repl is much better for this...
imo
Shouvik Roy
@royshouvik
Aug 01 2015 11:53
I understant , and I use repl a lot myself, but I would recommend you check out the chrome debugger if you have not already
Its wonderful , we dont have to insert console.log to print out values
evaristoc
@evaristoc
Aug 01 2015 11:53
I am just debugging it but @xeno-j already left the channel... I was just trying to help him...
@royshouvik thanks, I usually use Firefox for that but I will give it try to the Chrome one...
Shouvik Roy
@royshouvik
Aug 01 2015 11:56
@evaristoc oh, I think FireBug is equally good, also, Cloud9 has built in debugger, makes life pretty easy
I am just learning JS, and I was doing console.log to debug my code, and then when I found out the debugger, it made my life a lot easier :)
Hewhoshallbenamed
@Hewhoshallbenamed
Aug 01 2015 12:00
How do I use codecademy to learn Jquery ?
Its very confusing :/
k
jtezuka
@jtezuka
Aug 01 2015 12:02
Hi, could someone kindly help with my Chunky Monkey (splitting an array of strings into a multidimensional array) challenge?
My code only fills the first element in my new array

'''function chunk(arr, size) {
// Break it up.
var arrays=[];
var a=0;

for (i=0;i<size;i++) {
var i=[];
for (j=0; j<size;j++) {
i.push(arr[j]);
}

arrays[a]=i;
a++;

}
return arrays;
}

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

```function chunk(arr, size) {
// Break it up.
var arrays=[];
var a=0;

for (i=0;i<size;i++) {
var i=[];
for (j=0; j<size;j++) {
i.push(arr[j]);
}

arrays[a]=i;
a++;

}
return arrays;
}

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

function chunk(arr, size) {
  // Break it up.
var arrays=[];
var a=0;

  for (i=0;i<size;i++) {
    var i=[];
    for (j=0; j<size;j++) {
    i.push(arr[j]);
    }

    arrays[a]=i;
    a++;




}
  return arrays;
}



chunk(['a', 'b', 'c', 'd'], 2);
Jorge Almeida
@Jorgixhallo
Aug 01 2015 12:04
@Hewhoshallbenamed You just follow the tutorial they give you. I highly recommend that you create an account there. It's very usefull for other topics (like ruby, python, etc) and they explain everything very well. Html is so much better explained than in FreeCodeCamp.
Hewhoshallbenamed
@Hewhoshallbenamed
Aug 01 2015 12:05
Oh okay @Jorgixhallo Thank YOU :D
evaristoc
@evaristoc
Aug 01 2015 12:06
This message was deleted

@jtezuka Can I advise you to first check what other people have been recommending to solve that exercise (and any other problem) by going through the Search of the Gitter channel and query for "Chunky Monkey"?

You will be surprise how common your problem is... You could find several solutions to the same problem: check as many solutions as possible: they can be useful for different problems...

You can come back if that is not enough for you to understand...

Hewhoshallbenamed
@Hewhoshallbenamed
Aug 01 2015 12:09
@Jorgixhallo so do I learn HTML from the beginning over there at codecademy ?
jtezuka
@jtezuka
Aug 01 2015 12:11
@evaristoc Thanks for the tip. I found other solutions, but I was wondering specifically (for mine) what the error was. It seems that, unless i understand why my code does not work, i wouldn't really understand the mistake i made and would likely repeat it
evaristoc
@evaristoc
Aug 01 2015 12:12
@jtezuka Ok... let's debug the problem together?
@royshouvik was advising to use Chrome Debugger... but I would feel myself more comfortable using https://repl.it/languages/JavaScript... Can you try that link?
jtezuka
@jtezuka
Aug 01 2015 12:14
@evaristoc sure, that would be great!
i'm using the link now
How should i proceed?
evaristoc
@evaristoc
Aug 01 2015 12:17
Copy and paste your code there (I did it with the last you showed, I am not sure if that is what you want:
function chunk(arr, size) { // Break it up.
var arrays=[];
 var a=0;
 for (i=0;i<size;i++) {
 var i=[];
 for (j=0; j<size;j++) {
 i.push(arr[j]); } 
arrays[a]=i;
 a++; }
 return arrays; }

 chunk(['a', 'b', 'c', 'd'], 2);
@jtezuka what should you solution looks like?
jtezuka
@jtezuka
Aug 01 2015 12:19
right, i posted it there and saved it
=> [ [ 'a', 'b' ] ]
evaristoc
@evaristoc
Aug 01 2015 12:19
You don't have to save it, but that is ok...
jtezuka
@jtezuka
Aug 01 2015 12:19
the correct solution, given the parameters, should be => [ [ 'a', 'b' ] ,[ 'c', 'd' ] ]
evaristoc
@evaristoc
Aug 01 2015 12:21
@jtezuka hmm... let's see... first, what you are doing right? you are getting at least the first two...
When you are learning, a way to see the code is using console.log(xxx)
@jtezuka Find a point in the loop where you think a console.log will provide you relevant info. First check the first loop and the "size" parameter. Is that correct? Think that you need to go over the full length of the arr to also get the last two...
@jtezuka your iteration values are i and j... check if you are correctly visiting the arr
evaristoc
@evaristoc
Aug 01 2015 12:27
@jtezuka are you trying?
jtezuka
@jtezuka
Aug 01 2015 12:27
yes, i am
sorry, i was trying to think
i think part of the reason it's not working is because i declare 'i' several times
or, in two different areas as they different types. in the for as a number and later as an array
evaristoc
@evaristoc
Aug 01 2015 12:29
@jtezuka no, that is not the problem: just check with a console.log if what you are doing with the iteration just by printing to the console the values of i and j
jtezuka
@jtezuka
Aug 01 2015 12:32
so, having a i change from a number to an array has no effect once it loops over?
evaristoc
@evaristoc
Aug 01 2015 12:32
@jtezuka just an Observation: keep in mind that I am trying to work YOUR solution. It is possible that you are using the wrong approach, so you should have some idea WHY is that. As I told you, there are other solutions to this problem, few of them the most popular one...
lauratalaat
@lauratalaat
Aug 01 2015 12:32

@lauratalaat
Hi. Can anyone help me? I have to do this:Now you have to create different scenarios. Good thing we know how to do that using if / else statements.

If userAnswer is "yes", print out: "You and Bieber start racing. It's neck and neck! You win by a shoelace!"

Otherwise, print out: "Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'"

Remember: = is for assignment, and === is to check if things are equal!
and my code is:
what it is wrong? :(

// Check if the user is ready to play!
confirm("Are you ready to play");
console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");
console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'");
var userAnswer=prompt("Do you want to race Bieber on stage?");
if(userAnswer==="yes"){
console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!");
}
else{
console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");
}
evaristoc
@evaristoc
Aug 01 2015 12:34
@jtezuka sorry, yes: THAT part is incorrect: you should not change the variable type in this case: it is always recommended to have different names per variable.
jtezuka
@jtezuka
Aug 01 2015 12:35
ok, let me try to figure out how to declare it. Thanks for the help
evaristoc
@evaristoc
Aug 01 2015 12:36
@jtezuka no problem.
This message was deleted
Vitalii Danylov
@vitaliidanylov
Aug 01 2015 12:42

Hi everyone! Who can help with the next task Bonfire: Sum All Odd Fibonacci Numbers
```function sumFibs(num){
var arr = [];
var sum = 0;
arr[0] = 1;
arr1 = 1;
for(var i=2; i<num; i++){
arr[i] = arr[i-2]+arr[i-1];
}
for(var j=0; j<arr.length; j++){
if(arr[j]===0 || arr[j]%2===1){
sum += arr[j];
}
}
return sum;
}

sumFibs(4);
```

evaristoc
@evaristoc
Aug 01 2015 12:42
@jtezuka Sorry... (accidentally deleted)... in YOUR solution (after renaming the i array), with the first for-loop you are looping as many times as "size"; with the second, you are visiting the elements in the array which index is lower than size...
Nicholas Gibson
@promethi0s
Aug 01 2015 12:43
function sumFibs(num){
var arr = [];
var sum = 0;
arr[0] = 1;
arr1 = 1;
for(var i=2; i<num; i++){
arr[i] = arr[i-2]+arr[i-1];
}
for(var j=0; j<arr.length; j++){
if(arr[j]===0 || arr[j]%2===1){
sum += arr[j];
}
}
return sum;
}
sumFibs(4);
evaristoc
@evaristoc
Aug 01 2015 12:43
@jtezuka HINT: there is a method in JS that you can use to simply split an array in a chosen point
Vitalii Danylov
@vitaliidanylov
Aug 01 2015 12:45
test
evaristoc
@evaristoc
Aug 01 2015 12:48
@lauratalaat what is your result with your current code?
jtezuka
@jtezuka
Aug 01 2015 12:49
@evaristoc Thanks for the tip. I'll likely need to use the commonly used solution
Vitalii Danylov
@vitaliidanylov
Aug 01 2015 12:51

Hi everyone! Who can help with the next task Bonfire: Sum All Odd Fibonacci Numbers
`function sumFibs(num){
var arr = [];
var sum = 0;
arr[0] = 1;
arr1 = 1;
for(var i=2; i<num; i++){
arr[i] = arr[i-2]+arr[i-1];
}
for(i=0; i<arr.length; i++){
if(arr[i]===1 || arr[i]%2===1){
sum += arr[i];
}
}
return sum;
}

sumFibs(4);`

leanliam
@leanliam
Aug 01 2015 12:52
What's wrong with this code? var isEven = function(number) {
if (isEven % 2) {
return true;
} else {
return false;
}
};
Nicholas Gibson
@promethi0s
Aug 01 2015 12:53
@vitaliidanylov You have a couple problems: first off, you have a typo. I assume arr1 should be arr1?
evaristoc
@evaristoc
Aug 01 2015 12:53

@jtezuka no problem; still I really think that you were correctly exploring things: those methods are blackboxes that package things like that you were trying... so don't stop trying now an then

And try to learn how to debug your codes, otherwise you will be find yourself with problems where you will be stuck without exit...

Vitalii Danylov
@vitaliidanylov
Aug 01 2015 12:53
@leanliam (isEven%2 === 0
)
leanliam
@leanliam
Aug 01 2015 12:54
Ah...thanks so much @vitaliidanylov
Nicholas Gibson
@promethi0s
Aug 01 2015 12:54
@vitaliidanylov Your next problem is you're going way too far with your for loop. You need to stop iterating when when arr[i] > num
evaristoc
@evaristoc
Aug 01 2015 12:54
@vitaliidanylov is not @promethi0s giving you a possible solution?
leanliam
@leanliam
Aug 01 2015 12:55
@vitaliidanylov : Here's the error I get: Looks like your function returns false when number = 2
Vitalii Danylov
@vitaliidanylov
Aug 01 2015 12:56
@evaristoc i think this is my solution packed in code brackets or not?
evaristoc
@evaristoc
Aug 01 2015 12:57

@vitaliidanylov sorry, I don't understand... what do you mean?

Can I also advise you to check what other people have been recommending to solve that exercise (and any other problem) by going through the Search of the Gitter channel and query for the name of the Bonfire?

You will be surprise how common your problem is...

You can come back if that is not enough for you to understand or want to explore other approach...

Nicholas Gibson
@promethi0s
Aug 01 2015 12:57
@leanliam You don't want to test if isEven is divisible by two. You want to test if number is
leanliam
@leanliam
Aug 01 2015 12:58
@promethi0s , thanks! :)
evaristoc
@evaristoc
Aug 01 2015 13:00
@vitaliidanylov did you mean the tilde ("`") character?
Vitalii Danylov
@vitaliidanylov
Aug 01 2015 13:00
@evaristoc yes
evaristoc
@evaristoc
Aug 01 2015 13:01
Should be three times the character before and after the code to format it as a code.
Vitalii Danylov
@vitaliidanylov
Aug 01 2015 13:02
code
evaristoc
@evaristoc
Aug 01 2015 13:02
Perfect!
for one line... but 3 times for a longer one
Nicholas Gibson
@promethi0s
Aug 01 2015 13:03
Or, for blocks:
-code -
hrmm, thought that wouldn't register
Vitalii Danylov
@vitaliidanylov
Aug 01 2015 13:03
@evaristoc I've sent it like you recomended me but it appeared in regular view
evaristoc
@evaristoc
Aug 01 2015 13:03
At the right hand side of text area you are writing on there is a icon that would show the Markdown rules...
Do you see it?
Vitalii Danylov
@vitaliidanylov
Aug 01 2015 13:04
@evaristoc yes, first of all I looked there
evaristoc
@evaristoc
Aug 01 2015 13:05
ok... then write the tilde ("`") three times a line before and then three times a line after writing your code
Vitalii Danylov
@vitaliidanylov
Aug 01 2015 13:06
test line for code message
but what about test
it looks similar
xxxx 'xxx' - what is the difference
jtezuka
@jtezuka
Aug 01 2015 13:07
@evaristoc I ended up using the slice option and it ends up much cleaner than i could've done it with my original code, so thanks:)
function chunk(arr, size) {
  // Break it up.
var array=[];

for (i=0;i<arr.length;i+=size) {
  array.push(arr.slice(i,size+i)); 

}


  return array;
}



chunk(['a', 'b', 'c', 'd'], 2);
evaristoc
@evaristoc
Aug 01 2015 13:07
@jtezuka Excellent!
Vitalii Danylov
@vitaliidanylov
Aug 01 2015 13:10
@promethi0s exuse me, but why it should stop iterating, we a looking for sum of elements...so like I understand we should stop at the last element
test
ok, now I see
evaristoc
@evaristoc
Aug 01 2015 13:12
@vitaliidanylov Excellent!
Vitalii Danylov
@vitaliidanylov
Aug 01 2015 13:13
@evaristoc Thank you for your patience)
but what about the code
function oddSum(num){
    var arr = [];
    var sum = 0;
    arr[0] = 1;
    arr[1] = 1;
    for(var i=2; i<num; i++){
        arr[i] = arr[i-2]+arr[i-1];
    }
    for(i=0; i<arr.length; i++){
        if(arr[i]===1 || arr[i]%2===1){
            sum += arr[i];
            }
        }
    return sum;
    }

oddSum(1785);
The logic is we put all element of Fibonacci sequence in array except of first two
then we check if element is 1 or odd and add it to sum veriable. Could you please explain what's wrong? Maybe be it's obvious, but I can't see it...
evaristoc
@evaristoc
Aug 01 2015 13:19
@vitaliidanylov have you look at the comments by @promethi0s and @leanliam? What do you think about those comments?
leanliam
@leanliam
Aug 01 2015 13:19
This message was deleted
@vitaliidanylov how did u do the screenshot here? And how did create another line of sentence without clicking on "Enter"?
evaristoc
@evaristoc
Aug 01 2015 13:20
@leanliam At the right hand side of text area you are writing on there is an icon that would show the Markdown rules... Hope this helps
Vitalii Danylov
@vitaliidanylov
Aug 01 2015 13:21
@leanliam ``` then press shift + enter and then put your code between these kind of brackets
@evaristoc I'ven't understood why it should stop interating if num < arr[i]
I don't know how to capitalize the argument[2]
at least my func isn't working capFirst();
somebody to help me out ? :D
evaristoc
@evaristoc
Aug 01 2015 13:26
@vitaliidanylov Have you tried to debug? Shall we visit repl.it to see what happens?
leanliam
@leanliam
Aug 01 2015 13:27
testing: blah blah blah
testing: '''var isEven = function(number) {
if (number%2 === 0) {
return true;
} else if (isNaN(number)) {
return "Your input is not a number."
} else {
return false;
}
};'''
testing once more: ''' var isEven = function(number) {
if (number%2 === 0) {
return true;
} else if (isNaN(number)) {
return "Your input is not a number."
} else {
return false;
}
}; '''
Omar
@oab00
Aug 01 2015 13:28
use ` instead of '
Vitalii Danylov
@vitaliidanylov
Aug 01 2015 13:29
almost)
leanliam
@leanliam
Aug 01 2015 13:29
thanks @oab00 ...testing again... var isEven = function(number) { if (number%2 === 0) { return true; } else if (isNaN(number)) { return "Your input is not a number." } else { return false; } };
sawdagar
@heemadri
Aug 01 2015 13:29
Is there anyone who can help to know more about Uncomment.
evaristoc
@evaristoc
Aug 01 2015 13:29
@leanliam not the "'" but the "`" character... it is on the top left of your keyboard
Omar
@oab00
Aug 01 2015 13:30
do 3 of them for multiple line ^^
evaristoc
@evaristoc
Aug 01 2015 13:30
@leanliam good: three times the character a line before the code and three times a line after the code
leanliam
@leanliam
Aug 01 2015 13:31
testing... var isEven = function(number) {
Eko Julianto Salim
@ekojsalim
Aug 01 2015 13:31
@vitaliidanylov
function oddSum(num) {
    var arr = [];
    var sum = 0;
    arr[0] = 1;
    arr[1] = 1;
    for(var i = 2; arr[i - 1] + arr[i - 2] <= num; i++){
        arr[i] = arr[i-2]+arr[i-1];
    }
    for(i = 0; i < arr.length; i++){
        if(arr[i]===1 || arr[i]%2===1){
            sum += arr[i];
        }
    }
    return sum;
}
leanliam
@leanliam
Aug 01 2015 13:31
thanks @evaristoc and @vitaliidanylov and @oab00
evaristoc
@evaristoc
Aug 01 2015 13:32
@vitaliidanylov I don't remember what it is the question of the problem
Eko Julianto Salim
@ekojsalim
Aug 01 2015 13:32
@vitaliidanylov you should stop when the current fibonacci number in the iteration is equal or more than the num, not when the length of the array (AKA i) is equal or more than the num
Omar
@oab00
Aug 01 2015 13:33
@heemadri what is uncomment :o
sawdagar
@heemadri
Aug 01 2015 13:34
@oab00 I found it on my challenge no.25 The topic is Waypoint: Uncomment HTML.
evaristoc
@evaristoc
Aug 01 2015 13:34
@vitaliidanylov I think that what @ekojsalim and others have commented is just a requirement of the problem... the rest, your for loop correctly select and sum the values
Paul Soper
@pdsoper
Aug 01 2015 13:34
@oab00 It means to remove the markers tht disable a section of code. For HTML they are <!— and —>
evaristoc
@evaristoc
Aug 01 2015 13:36
people leaving! happy freecoding!
Omar
@oab00
Aug 01 2015 13:36
ah right so you just need to remove these comment tags @heemadri
later @evaristoc
sawdagar
@heemadri
Aug 01 2015 13:39
yeah! I do this. But my question is why or when I use this uncomment tags. I can delete any anything which I dont need. Can I clear my query @oab00 & @evaristoc?
Dieison Stein
@dieisonstein
Aug 01 2015 13:40
guys, i need help, how can i post here where im stuck?
Omar
@oab00
Aug 01 2015 13:43
@heemadri you won't need it to delete tags really ..
you can use it to add your own comments like
<!-- here's my comment about this section --> to make it more organised
@dieisonstein which challenge are u stuck on?
Dieison Stein
@dieisonstein
Aug 01 2015 13:44
@oab00 Waypoint: Use CSS Selectors to Style Elements
leanliam
@leanliam
Aug 01 2015 13:44
@dieisonstein just copy and paste your code here
Dieison Stein
@dieisonstein
Aug 01 2015 13:45

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

<h2>CatPhotoApp</h2>

<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>

how do i apply it to the h2 element
sawdagar
@heemadri
Aug 01 2015 13:47
Thank you very much for your help @oab00 ! now i understand..
Omar
@oab00
Aug 01 2015 13:48
great :smile:
@dieisonstein if you look at the problems at the bottom left of the page it says you need to make the h2 element blue coloured
Dieison Stein
@dieisonstein
Aug 01 2015 13:49
@oab00 no, it should be red
@oab00 Your h2 element should be red.
Your h2 element should have the class "red-text".
Omar
@oab00
Aug 01 2015 13:50
oh it's the next waypoint sry
@dieisonstein alright you can add the class to the element using
<h2 class="class-name">
Dieison Stein
@dieisonstein
Aug 01 2015 13:52
ok, it goes inside the style then? @oab00
Omar
@oab00
Aug 01 2015 13:53
no no
in the html tag below it
<style>
.red-text {
  color:red;
}
</style>

<h2 *goes-right-here*>CatPhotoApp</h2>
<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
Dieison Stein
@dieisonstein
Aug 01 2015 13:55
oh man, thanks
leanliam
@leanliam
Aug 01 2015 14:16
My error says "It looks like your function doesn't return false when hungry is false." What's wrong?
var hungry = true;
var foodHere = true;

var eat = function() {
  if (hungry && foodHere) {
    console.log("Me too. Let's eat!"); 
  } else if (!(hungry || foodHere)) {
      console.log("Okay, we can keep looking.");
  } else {
      console.log("Not sure where else to go.")
  }
};
I did it! :-D
@dieisonstein were you able to figure it out?
Dieison Stein
@dieisonstein
Aug 01 2015 14:19
@leanliam yes, thank you
leanliam
@leanliam
Aug 01 2015 14:19
@dieisonstein they're all awesome here....so helpful!
Dieison Stein
@dieisonstein
Aug 01 2015 14:20
@leanliam yes, very helpful
leanliam
@leanliam
Aug 01 2015 14:20
:)
Jeff Bynum
@bynumjj
Aug 01 2015 14:39
Screen Shot 2015-07-31 at 5.29.36 PM.png
SEEK and DESTROY help — this code returns the array of arguments that are to be deleted. The problem is in defining the filter function, I think. Either because it contains a loop or the “value” isn’t defined properly. Any suggestions?
jordanelizaga
@jordanelizaga
Aug 01 2015 14:41
I am trying to do the ziplines but I don't understand exactly how to use APIs. I understand jquery and vanilla js and bootstrap but I'm not sure how to use APIs
Craig Morrison
@frogmorton
Aug 01 2015 14:43
I have a working solution for Bonfire #27, sorted union.... with 2 questions about it. 1) I'm not sure how the hash works (I found this solution in a Stack Overflow thread) and also, it violates the DRY rule (I repeat virtually the same code block 3 times)
I'll post it either here or in PM, if someone can help with the explanation / refactoring ...
Craig Morrison
@frogmorton
Aug 01 2015 14:48
    function unite(arr1, arr2, arr3){
    var hash = {};
    var ret = [];

    for(var i=0; i < arr1.length; i++){
        var elem = arr1[i];
        if (!hash[elem]){
            hash[elem] = true;
            ret.push(elem);
        }
    }

    for( i=0; i < arr2.length; i++){
        elem = arr2[i];
        if (!hash[elem]){
            hash[elem] = true;
            ret.push(elem);
        }
    }

    for( i=0; i < arr3.length; i++){
        elem = arr3[i];
        if (!hash[elem]){
            hash[elem] = true;
            ret.push(elem);
        }
    }
    return ret;
}

unite([11, 1, 2, 3], [9, 5, 2, 1, 4], [2, 13, 1]);
well, here it is...
L. Becker
@LCBecker
Aug 01 2015 14:49
@jordanelizaga I can help you with that
What don't you understand about APIs?
jordanelizaga
@jordanelizaga
Aug 01 2015 14:50
how to get them
Craig Morrison
@frogmorton
Aug 01 2015 14:55
Anyone a coding guru, who can explain in simple terms how a hash lookup table works, and suggest and approach about eliminating the repetition in this solution??
Omar
@oab00
Aug 01 2015 14:59
hash here looks like it's checking for each number to see if you've already pushed it to the return array or not
hash[elem] try for example hash[11] it will return false initially but true after 11 is pushed to the array
and for the repeated factor you can make a 2-d array to include all the arrays
var arrayList = [arr1, arr2, arr3]; and then make nested for loops
or you could use the arguments object
Craig Morrison
@frogmorton
Aug 01 2015 15:02
yes, that's right @oab00 ... i just didn't know exactly how it checks...
Dieison Stein
@dieisonstein
Aug 01 2015 15:02
how can i change the width of the image? where do i put the code? I tried everywhere, inside the style, after the class "smaller -image" inside too, anyone know?
Bianca Mihai
@biancamihai
Aug 01 2015 15:02
@frogmorton what if you merge the 3 arrays toughener? and then you have just one array to worry about and not repeat your code 3 times
? https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/concat
@frogmorton it checks to see if the element doesn't already exist
it checks to see if it is unique
Craig Morrison
@frogmorton
Aug 01 2015 15:03
@biancamihai I think i understand your suggestion, let me try it
Bianca Mihai
@biancamihai
Aug 01 2015 15:04
  1. concat the arrays
  2. you can use the same method that you use now to get an unique array
  3. good luck ;)
L. Becker
@LCBecker
Aug 01 2015 15:04
Is there any way to hide API keys in CodePen?
Bianca Mihai
@biancamihai
Aug 01 2015 15:05
@LCBecker I don't think it is ...
Craig Morrison
@frogmorton
Aug 01 2015 15:05
@oab00 @biancamihai thanks for your suggestions... I'll try both
Dieison Stein
@dieisonstein
Aug 01 2015 15:06
<img class="smaller-image" src='https://bit.ly/fcc-kittens'/> anyone know where does the code for the width of the image goes?
Craig Morrison
@frogmorton
Aug 01 2015 15:06
@oab00 I'm not super comfortable with the arguments object, not sure how I'd use it in this case
Bianca Mihai
@biancamihai
Aug 01 2015 15:07
@dieisonstein what waypoint ?
Dieison Stein
@dieisonstein
Aug 01 2015 15:07
@biancamihai 19
Alex
@awulkan
Aug 01 2015 15:08
Hello everyone
Bianca Mihai
@biancamihai
Aug 01 2015 15:09
@dieisonstein create a class smaller-image in css and look at with https://developer.mozilla.org/en-US/docs/Web/CSS/width
Alex
@awulkan
Aug 01 2015 15:10
Does anyone have time to explain just how Global Object, Object.hasOwnProperty() and Object.keys() can be used to solve the "Bonfire: Where art thou"? I have solved it without them, but I don't understand how these things can be used in this bonfire.
Bianca Mihai
@biancamihai
Aug 01 2015 15:10
@dieisonstein if you expand the description, just click on the "More information" button, you will get tips on how to solve this waypoints ;)
Dieison Stein
@dieisonstein
Aug 01 2015 15:11
@biancamihai thanks for the link, my second day here, and im totally new to coding, still look like the matrix haha
Bianca Mihai
@biancamihai
Aug 01 2015 15:11
@AlexWulkan I didn't always follow the suggestions :)
Alex
@awulkan
Aug 01 2015 15:12
@biancamihai Me neither, but I don't understand how those things work. :/
Bianca Mihai
@biancamihai
Aug 01 2015 15:12
haha @dieisonstein don't worry I'm sure you are doing great ;)
Omar
@oab00
Aug 01 2015 15:13
@frogmorton
for (argument in arguments) {
        argument = arguments[argument];

        // copy paste a for loop here and replace
        // arr1 with argument
}
Craig Morrison
@frogmorton
Aug 01 2015 15:15
@oab00 thanks!
Bianca Mihai
@biancamihai
Aug 01 2015 15:16
@AlexWulkan you can use Object.keys() to get the keys of an object https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys it gives you an array and you can use Object.hasOwnProperty() to check if the object has a property https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty (mdn is my best friend) so I guess they want you to loop an array of keys and check if the property exists...
Juan Martínez
@jbmartinez
Aug 01 2015 15:16
hello everyone
I'd like to hear your opinion about my wikipedia viewer zipline
Dieison Stein
@dieisonstein
Aug 01 2015 15:17
@biancamihai can you help me a litle more? i created the class smaler image , but still cant change the width dont really understood that link u send me
Bianca Mihai
@biancamihai
Aug 01 2015 15:19

@dieisonstein if you click the "More info" button you will see this:

Create a class called smaller-image and use it to resize the image so that it's only 100 pixels wide.

CSS has an attribute called width that controls an element's width. Just like with fonts, we'll use pixels(px) to specify the image's width.

For example, if we wanted to create a CSS class called "larger-image" that gave HTML elements a width of 500 pixels, we'd use: <style> .larger-image { width: 500px; } </style>.

so you have here an example of how to create a class that will resize an image to 500px, now you will have to do a class to resize the image to 100px ;)

Feners4
@Feners4
Aug 01 2015 15:20
@jbmartinez sweeet
Dieison Stein
@dieisonstein
Aug 01 2015 15:21
@biancamihai damn, i read that, but i think i didnt understand what they meant, thank you again!!
Juan Martínez
@jbmartinez
Aug 01 2015 15:21
@Feners4 thanks!
Bianca Mihai
@biancamihai
Aug 01 2015 15:21
:) np @dieisonstein almost all the problems have the solutions in the description, pay attention :D
Omar
@oab00
Aug 01 2015 15:22
@jbmartinez that's pretty awesome with the animation
I suggest including target="_blank" in your <a> links
Dieison Stein
@dieisonstein
Aug 01 2015 15:22
@biancamihai ok+
Juan Martínez
@jbmartinez
Aug 01 2015 15:22
@oab00 you're right, I'm gonna add it
ready. Jade makes HTML editing so easy!
@oab00 thanks for the suggestion
Bianca Mihai
@biancamihai
Aug 01 2015 15:26
@jbmartinez works and looks good! take a look at https://developer.mozilla.org/en-US/docs/Web/CSS/outline if you want to lose that blue border around your text input on focus ;)
Juan Martínez
@jbmartinez
Aug 01 2015 15:27
@biancamihai I knew I forgot something! Thank you
Alex
@awulkan
Aug 01 2015 15:28
@biancamihai I don't get it though. What use does keys() and hasOwnProperty() serve? I tried adding it to my code, but it works fine without it.

With keys and hasOwnProperty:

function where(collection, source) {
  var arr = [];

  for(var name in collection){
    if(Object.keys(collection[name].hasOwnProperty('first' && 'last')) && collection[name].last === source.last){
      arr.push(collection[name]);
    }
  }
  return arr;
}
where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });

Without:

function where(collection, source) {
  var arr = [];

  for(var name in collection){
    if(collection[name].last === source.last){
      arr.push(collection[name]);
    }
  }
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
Feners4
@Feners4
Aug 01 2015 15:33
@jbmartinez hey I've been trying since yesterday to set up my ng-repeat but I have been unsuccessful..
@jbmartinez can you help?
Alex
@awulkan
Aug 01 2015 15:34
Got to go, cya
Bianca Mihai
@biancamihai
Aug 01 2015 15:35
@AlexWulkan then perhaps the tests should be more strict? what happens if you would have had a test with an attribute that didn't exist? so collection[name].last would give you an error right?
and about the Object.keys I think they want you to use it so you don't use for(var name in ...)
Juan Martínez
@jbmartinez
Aug 01 2015 15:37
@Feners4 sure
Feners4
@Feners4
Aug 01 2015 15:38
@jbmartinez first, should the ng.repeat go in my html(jade)?
or my javascript?
Juan Martínez
@jbmartinez
Aug 01 2015 15:38
@Feners4 in html
@Feners4 use ng-repeat on the html element that you want to repeat, it could be a li element, for example
Feners4
@Feners4
Aug 01 2015 15:42
@jbmartinez so in my codepen http://codepen.io/Feners4/pen/EjONEe
@jbmartinez how can I populate my list?
@jbmartinez Im so lost right now lol..
Juan Martínez
@jbmartinez
Aug 01 2015 15:49

@Feners4 assuming your data is ready to use, you could do something similar to this:

.show-data(ng-repeat="user in users")
        .name {{user.username}}
        .status {{user.status}}

I'm assuming your data is stored in users array

@Feners4 it seems you're using getdata, so you should write ng-repeat="user in getdata"
Feners4
@Feners4
Aug 01 2015 15:55
@jbmartinez yeah, but how does this populate my list or how will this display my data?
Juan Martínez
@jbmartinez
Aug 01 2015 15:57
the html will be populated automagically if getdata is an array with your data
@Feners4 you should put your data in getdata with $http.get() or something similar
Feners4
@Feners4
Aug 01 2015 15:58
@jbmartinez
main(ng-app='heyTwitch')
  section(ng-controller='MainCtrl')
    header
      ul#mainMenu
        li(data-display='getdata').activeMenu All
        li(data-display='onlineUsers') Online
        li(data-display='offlineUsers') Offline

        .show-data(ng-repeat="user in getdata")
        .name {{user.username}}
        .status {{user.status}}
Juan Martínez
@jbmartinez
Aug 01 2015 15:58
perhaps you'll need some transformation
Soumya Rauth
@soumyaRauth
Aug 01 2015 15:58
Any beginner here?
Juan Martínez
@jbmartinez
Aug 01 2015 16:00
@Feners4 what are you using data-display for?
Feners4
@Feners4
Aug 01 2015 16:01
because later on I will be adding the switching between list function
this way I display each list when its button is clicked, right?
Juan Martínez
@jbmartinez
Aug 01 2015 16:02
I think I understand, but that's not done by angular magic
you may need to wrap your new divs in a parent div to hide and show data
Feners4
@Feners4
Aug 01 2015 16:05
@jbmartinez could that be why my data not showing?
the data-displays?
Moisés Man
@moigithub
Aug 01 2015 16:05
@Feners4 i think u need to add some indentation to ur last 2 lines (name/status )
Juan Martínez
@jbmartinez
Aug 01 2015 16:06
@Feners4 your data has a very different format
@moigithub each element in getdata is an array, username is in element[0]
@moigithub sorry, I wanted to mention @Feners4
@moigithub is right, you need to indent the last two lines, @Feners4
and use user[0] instead of user.username
Juan Martínez
@jbmartinez
Aug 01 2015 16:11
but still it doesn't display anything
Alex
@awulkan
Aug 01 2015 16:15
@biancamihai Are you still there?
Craig Morrison
@frogmorton
Aug 01 2015 16:22
why isn't my if... statement running?
function convert(str) { // &colon;&rpar; var regexArr = ["&", "<", ">", '"', "'"]; var charEntArr = ['&amp;', '&lt;', '&gt;', '&quot;', '&apos;']; console.log(regexArr); console.log(charEntArr); for (var i = 0; i < str.length; i++) { if(str.charAt(i) === regexArr[i]) { str = str.replace(str.charAt(i), charEntArr[i]); console.log(str); } } console.log(str); return str; } convert('Dolce & Gabbana');
WTH??
function convert(str) {
  // &colon;&rpar;
  var regexArr = ["&", "<", ">", '"', "'"];
  var charEntArr = ['&amp;', '&lt;', '&gt;', '&quot;', '&apos;'];
  console.log(regexArr);
  console.log(charEntArr);
  for (var i = 0; i < str.length; i++) {
        if(str.charAt(i) === regexArr[i]) {
            str = str.replace(str.charAt(i), charEntArr[i]);
            console.log(str);
        }
  }
  console.log(str);
  return str;
}

convert('Dolce & Gabbana');
is my if condition illegal? my use of replace?
Juan Martínez
@jbmartinez
Aug 01 2015 16:25
@frogmorton I think your ifis running fine
you're comparing one character to multiple characters, it will be always false
str.chartAt(i) returns only on character
Feners4
@Feners4
Aug 01 2015 16:27
@jbmartinez let me try..
Craig Morrison
@frogmorton
Aug 01 2015 16:27
@jbmartinez the array regexArr, the elements are only one char each
Juan Martínez
@jbmartinez
Aug 01 2015 16:27
nvm, I understand now @frogmorton
Craig Morrison
@frogmorton
Aug 01 2015 16:28
and the replace, yes, i'm trying to replace one char with multiple chars... not allowed?
Juan Martínez
@jbmartinez
Aug 01 2015 16:28
@frogmorton that replace is totally valid
but, in this case, the order of replacements is important
Craig Morrison
@frogmorton
Aug 01 2015 16:30
when i run it...and try to console.log str, I get the original string... nothing is replaced... Oh? how so?
Juan Martínez
@jbmartinez
Aug 01 2015 16:30
@frogmorton if you replac '&' after 'lt' you will end with &amp;lt; instead of &lt;
Craig Morrison
@frogmorton
Aug 01 2015 16:31
HA! got it
but ampersand IS first
in my code
Juan Martínez
@jbmartinez
Aug 01 2015 16:32
the problem is i in the loop, isn't it?
str and regexArr are different length but you're using i for both
Craig Morrison
@frogmorton
Aug 01 2015 16:34
oh, damn
because of white space and whatnot
wait....
sorry, brainf@rt
@jbmartinez I added the 2nd counter, and now my output is Dolce undefined Gabbana
that's actually positive news for me
Craig Morrison
@frogmorton
Aug 01 2015 16:40
the new loop structure seems to be working but, now i need to figure out the rest...
Juan Martínez
@jbmartinez
Aug 01 2015 16:40
@frogmorton yeah! a step forward :smile:
Bianca Mihai
@biancamihai
Aug 01 2015 16:44
@AlexWulkan I am now
Alex
@awulkan
Aug 01 2015 16:45
@biancamihai Okey, do you have time to help a confused person?
Talking about me.
Bianca Mihai
@biancamihai
Aug 01 2015 16:46
I can chat but can't talk now :| still about the object attributes? :)
can't talk because I'm with my little one now :D
Alex
@awulkan
Aug 01 2015 16:47
Yeh. I mean I understand that Object.keys(collection) will bring me the index of each object in the array. But I don't see how something like this will help me avoid using a for...in loop.
This is the code provided from scratch. Just so you know what I'm talking about.
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' });
Bianca Mihai
@biancamihai
Aug 01 2015 16:48
well you can use forEach on that array then
Alex
@awulkan
Aug 01 2015 16:49
Never used forEach.
Alex
@awulkan
Aug 01 2015 16:51
But what's the benefit of using forEach instead of 'for in'?
Eko Julianto Salim
@ekojsalim
Aug 01 2015 16:53
@AlexWulkan don't use for in for array iteration, there are some side effects
Alex
@awulkan
Aug 01 2015 16:53
Also, I have no clue of how to use that with keys() and hasOwnProperty() xD
Bianca Mihai
@biancamihai
Aug 01 2015 16:55
@AlexWulkan I think this is a good explanation http://stackoverflow.com/questions/9329446/for-each-over-an-array-in-javascript about what/where to use
and about how to use them I think you can get the array of keys then iterate and check if the attribute exists
if you want to solve the problem using this functions
your solution is working :)
Alex
@awulkan
Aug 01 2015 17:01
@biancamihai Thanks for the help, but I'm still super lost.
Possibly even more so now that forEach was introduced.
BandiniLec
@BandiniLec
Aug 01 2015 17:05
can i have a little help on the bonfire make a person? My setter is good, for example a function that set fullname to an object. But the getter keep saying that this.Fullname is undefined
even if in the setter it s define
Bianca Mihai
@biancamihai
Aug 01 2015 17:07
@AlexWulkan hmm, not good :) try to help and I get you more confused :D
@BandiniLec try to post your code, let's see if we can help :D
BandiniLec
@BandiniLec
Aug 01 2015 17:09
oh thanks
'code'
var Person = function(firstAndLast) {
var arr = firstAndLast.split(" ");
console.log(arr1);
var test = firstAndLast;
this.setFirstName = function() {
this.FirstName = arr[0];
console.log("SETFIRSTNAME : " + this.FirstName);
};
this.setLastName = function() {
this.LastName = arr1;
console.log("SETLASTNAME : " + this.LastName);
};
this.setFullName = function() {
this.FullName = test;
console.log("SETFULL NAME:" + this.FullName);
};
this.getFirstName = function() {
console.log("GetFirstName : " + this.FirstName);
return this.FirstName;
};
this.getLastName = function() {
console.log("GetLastName" + this.LastName);
return this.LastName;
};
this.getFullName = function() {
console.log("GetFullName : " + this.FullName);
return this.FullName;
};
return firstAndLast;
}; 'code'
shit
sorry
Bianca Mihai
@biancamihai
Aug 01 2015 17:16
@BandiniLec you didn't define your FirstName var
Feners4
@Feners4
Aug 01 2015 17:17
I've been trying since yesterday to get my data to display:
http://codepen.io/Feners4/pen/EjONEe
Helllllpppp PLzzzzz
BandiniLec
@BandiniLec
Aug 01 2015 17:18
wasn't it define by doing this?
this.setFirstName = function() {
this.FirstName = arr0
arr[0]
Nic Galluzzo
@ngalluzzo
Aug 01 2015 17:19
why don’t you use $http if you’re using Angular @Feners4 ?
Alex
@awulkan
Aug 01 2015 17:19
@biancamihai Ok, so I used a forEach loop, but I'm still not managing to get Object.keys() and hasOwnProperty() in there...
function where(collection, source) {
  var arr = [];

  collection.forEach(function(value){
    if(value.last === source.last){
     arr.push(value); 
    }
  });
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
Feners4
@Feners4
Aug 01 2015 17:20
@ngalluzzo how so?
Nic Galluzzo
@ngalluzzo
Aug 01 2015 17:20
instead of $.getJSON
Eko Julianto Salim
@ekojsalim
Aug 01 2015 17:21
@AlexWulkan you don't need hasOwnProperty there
its okay to use forEach there, but filter is more suited for this
Alex
@awulkan
Aug 01 2015 17:21
@ekojsalim But those are the two things referenced to in the bonfire.
leanliam
@leanliam
Aug 01 2015 17:22
Need help please. This is the error I get: ""It looks like your function doesn't return false when hungry is false."
var hungry = true;
var foodHere = true;

var eat = function() {
  if (hungry && foodHere) {
    console.log("Me too. Let's eat!"); 
  } else if (!(hungry || foodHere)) {
      console.log("Okay, we can keep looking.");
  } 
};
Eko Julianto Salim
@ekojsalim
Aug 01 2015 17:22
@AlexWulkan well, sometimes the helpful links is not so helpful at all
I will take the array.some link as an example
Alex
@awulkan
Aug 01 2015 17:22
@ekojsalim I still want to understand it though.
Eko Julianto Salim
@ekojsalim
Aug 01 2015 17:22
@AlexWulkan :) yeah
Nic Galluzzo
@ngalluzzo
Aug 01 2015 17:23
try !hungry || !foodHere
Eko Julianto Salim
@ekojsalim
Aug 01 2015 17:23
if you are approaching the problem as the way you are now, hasOwnProperty is basically useless
and don't hardcode the last there
the second test case doesn't use last
this is where you need to use Object.keys(source)
Alex
@awulkan
Aug 01 2015 17:23
@ekojsalim I know, but it still passes lol.
@ekojsalim So how would that part look then?
Eko Julianto Salim
@ekojsalim
Aug 01 2015 17:26
@AlexWulkan
function where(collection, source) {
  var keys = Object.keys(source)[0];
  return collection.filter(function(item) {
    return item[keys] === source[keys];
  });
}
Alex
@awulkan
Aug 01 2015 17:28
How am I supposed to know all of these functions that has not even been mentioned by FCC?
Eko Julianto Salim
@ekojsalim
Aug 01 2015 17:28
@AlexWulkan you haven't reached the functional programming part of FCC
Alex
@awulkan
Aug 01 2015 17:28
@ekojsalim no
Eko Julianto Salim
@ekojsalim
Aug 01 2015 17:28
but you can easily substitute the filter for simple for loop
anyway a more correct version that checks for each property of source is this
function where(collection, source) {
  var keys = Object.keys(source);
  return collection.filter(function(item) {
    return keys.every(function(key) {
      return item[key] === source[key];
    });
  });
}
@AlexWulkan you will learn those in due time
Alex
@awulkan
Aug 01 2015 17:30
And where would hasOwnProperty() be useful in something like this?
Eko Julianto Salim
@ekojsalim
Aug 01 2015 17:30
@AlexWulkan nowhere, it is unnecessary if you are using this approach
Alex
@awulkan
Aug 01 2015 17:30
@ekojsalim Yeh, but I'm trying to understand the appropach FCC wanted me to take.
Eko Julianto Salim
@ekojsalim
Aug 01 2015 17:32
@AlexWulkan okay :)
hasOwnProperty checks if an object has a property specified as an argument
Alex
@awulkan
Aug 01 2015 17:33
@ekojsalim Thanks for the help though, I'll read about the filter method later.
Eko Julianto Salim
@ekojsalim
Aug 01 2015 17:34
@AlexWulkan note that the bonfire is also built by campers like us, the helpful links is usually submitted by them, each people have different solutions to different problems :)
Alex
@awulkan
Aug 01 2015 17:35
@ekojsalim Yeh, just a bit frustrating. Some bonfires takes like 2 minutes to solve, others will keep me frustrated for a whole day.
Maybe not frustrated, but confused.
Eko Julianto Salim
@ekojsalim
Aug 01 2015 17:36
@AlexWulkan yeah, keep trying and you will get it :)
Vincenzo Pandolfo
@vincepandolfo
Aug 01 2015 17:38
Guys can I have your opinion on my Wikipedia Viewer? (Zipline project) Thanks! http://codepen.io/vincepandolfo/pen/BNvjwq
Alex
@awulkan
Aug 01 2015 17:38
@ekojsalim Hopefully. At least your solution is dynamic, unlike mine that just worked for some weird reason lol.
@vincepandolfo Looks nice. I don't think I'm skilled enough to review your code though. :)
Vincenzo Pandolfo
@vincepandolfo
Aug 01 2015 17:41
@AlexWulkan You will surely be one day :P
ninjatron
@ninjatron
Aug 01 2015 17:41
can someone explain me about Bonfire: Steamroller?
Eko Julianto Salim
@ekojsalim
Aug 01 2015 17:42
@vincepandolfo nice :) try using other framework or library for your next zipline
Vincenzo Pandolfo
@vincepandolfo
Aug 01 2015 17:42
@ekojsalim any suggestion? thanks!
Alex
@awulkan
Aug 01 2015 17:42
@vincepandolfo Maybe there should be a minimum size for the search bar? Just to make it usable on phones. :)
Eko Julianto Salim
@ekojsalim
Aug 01 2015 17:43
@ninjatron you need to flatten an array, see the test cases for example
you can use some tricks to solve this or you can use recursion and such
Vincenzo Pandolfo
@vincepandolfo
Aug 01 2015 17:43
@AlexWulkan that's an issue I had with the other ziplines too... I'm still not able to figure out how :/
why wont my data display?!
leanliam
@leanliam
Aug 01 2015 18:04
What's wrong here?

var hungry = true;
var foodHere = true;

var eat = function() {
if (hungry && foodHere) {
console.log("Alright, let's eat!");
} else if (hungry && !foodHere){
console.log("Okay, we can keep driving.");
} else {
console.log("Let's keep looking.")
}
};

Alex
@awulkan
Aug 01 2015 18:06
@leanliam What are you trying to accomplish?
There's a missing semicolon on the console log
at the end
You also might need to call the function with eat(); if that's a criteria.
@leanliam Do you get any error?
Raymond Ou
@hangway
Aug 01 2015 18:10
function mutation(arr) {
  var firstElement = arr[0].toLowerCase().split("");

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

    var index = firstElement.indexOf(arr[1][i].toLowerCase());

    if (index >= 0) {

      firstElement.splice(index,1);

      } else {

        return false;
      }
    }
 return true;
}

mutation(['hello', 'hey']);
i need help for Bonfire: Mutations
expect(mutation(['Mary', 'Aarmy'])).to.be.true;expected false to be true
leanliam
@leanliam
Aug 01 2015 18:12
@AlexWulkan , let me try
ninjatron
@ninjatron
Aug 01 2015 18:13
@ekojsalim i was thinking recursion, but didn't expect that it would be a recursion question since it's pretty advanced for this level
leanliam
@leanliam
Aug 01 2015 18:13

@AlexWulkan i just tried and i get the same error: "It looks like your function doesn't return false when hungry is false." Here's the updated code:

var hungry = true;
var foodHere = true;

var eat = function() {
if (hungry && foodHere) {
console.log("Alright, let's eat!");
} else if (hungry && !foodHere){
console.log("Okay, we can keep driving.");
} else {
console.log("Let's keep looking.");
}
};

eat();

Alex
@awulkan
Aug 01 2015 18:14
@leanliam Try returning false at the end then. :P
var hungry = false;
var foodHere = true;

var eat = function() {

  if (hungry && foodHere) {
    console.log("Alright, let's eat!");
  } else if (hungry && !foodHere){
    console.log("Okay, we can keep driving.");
  } else {
    return false;
  }
};

eat();
Eko Julianto Salim
@ekojsalim
Aug 01 2015 18:14
@ninjatron you don't really have to use recursion there, but it is a nice option for solving this bonfire
Alex
@awulkan
Aug 01 2015 18:16
@hangway I'm about to leave, so I can't look through your example right now. However, this is how I did it without the splice method: http://wulkan.me/bonfire-mutations/
leanliam
@leanliam
Aug 01 2015 18:17

@AlexWulkan ...ah...that part worked, but now have a different error ;) : " It looks like your function doesn't return true when hungry and foodHere are both true."

To understand my assignment, here's the instruction: "Create two variables, hungry and foodHere, and set them both equal to true. Inside the eat function, create an if statement that returns true only if both hungry and foodHere are true, and false otherwise. The function eat should take no input and hungry and foodHere should both be globals."

@AlexWulkan
var hungry = true;
var foodHere = true;

var eat = function() {
if (hungry && foodHere) {
console.log("Alright, let's eat!");
} else {
return false;
}
};

Alex
@awulkan
Aug 01 2015 18:18
Just replace the console.log with different return values. Just like in the "else" part where you return false.
Arthur Zhuk
@ug02fast
Aug 01 2015 18:18
This message was deleted
Nary Sovan
@nary-dev
Aug 01 2015 18:19
if (hungry && foodHere) {
return true;
} else {
return false;
}
leanliam
@leanliam
Aug 01 2015 18:20
@nary-dev ....that worked!!! thank you so much!!! :D
@AlexWulkan thank you too!
i can finally moved on :D
Alex
@awulkan
Aug 01 2015 18:20
@leanliam Np. It was much simpler than you thought it would be. :D
leanliam
@leanliam
Aug 01 2015 18:21
@AlexWulkan ...exactly...i made it more complicating! haha
Alex
@awulkan
Aug 01 2015 18:22
Good luck everyone, cya later!
leanliam
@leanliam
Aug 01 2015 18:22
@AlexWulkan see u!
ninjatron
@ninjatron
Aug 01 2015 18:30
@ekojsalim the only problem is that there is no way to know how many elements inside an array
so say i have while (Array.isArray(arr[j])) in some for loop
Mark Howard
@iheartkode
Aug 01 2015 18:40
array.length();
Felipe Ureta
@felipe-
Aug 01 2015 18:43
Hey guys Im on bonfire: sorted union, but I don’t understand what I have to do, I looked at the failing tests but I still don’t undertand.
union is asking where the arrays overlap
Raymond Ou
@hangway
Aug 01 2015 18:47
@AlexWulkan Thank you!
Felipe Ureta
@felipe-
Aug 01 2015 18:50
@Dadsaster OK I got confused with what the test was passing in and what the code was like in the code editor. thanks.
Oliver
@Dadsaster
Aug 01 2015 18:52
@felipe- that bonfire has confused a ton of people. I think I spent 3 days on it.
Melissa Yip
@su6a12
Aug 01 2015 18:59
hey everyone, i've been working on symmetric difference for way too long. it's working for the most part except for the first test. i don't know how to keep the order of the numbers.
Feners4
@Feners4
Aug 01 2015 19:02
still stuck on this...http://codepen.io/Feners4/pen/EjONEe
Hassan Mouhtadi
@hassanmouhtadi
Aug 01 2015 19:03
Hey guys, with the new upgrade of FCC, when I connect to an account I created before the upgrade, I don't see the new features they added, but with a new account you can see them, will they merge the things they added with the existing accounts, or until the beta's finish ?
Oliver
@Dadsaster
Aug 01 2015 19:04
I think only when beta goes live
Hassan Mouhtadi
@hassanmouhtadi
Aug 01 2015 19:05
Ok, so we just pursue the exercices normally
Oliver
@Dadsaster
Aug 01 2015 19:06
@su6a12 - it depends on your approach - can you post your code?
@hassanmouhtadi they didn't really discuss the integration - I would just do the exercises you are interested and expect it to merge at some point soon
Hassan Mouhtadi
@hassanmouhtadi
Aug 01 2015 19:09
@Dadsaster Many thanks :smile:
Melissa Yip
@su6a12
Aug 01 2015 19:12

function sym(args) {
var argsArr = Array.prototype.slice.call(arguments);
var result = [], count = {}, newArrList = [];

for(var a = 0; a < argsArr.length; a++) {
var currArr = argsArr[a], valuesSoFar = [];
for(var b = 0; b < currArr.length; b++) {
if (valuesSoFar.indexOf(currArr[b]) === -1) {
valuesSoFar.push(currArr[b]);
}
}
newArrList.push(valuesSoFar);
}

newArrList.filter(function(each, index) {
for(var i = 0; i < each.length; i++) {
  if (!count[each[i]]) {
    count[each[i]] = 1;
  }
  else{
    delete count[each[i]];
  }
}

});
for(var key in count) {
if (count.hasOwnProperty(key)) {
result.push(parseInt(key));
}
}
return result;
}

@Dadsaster sorry, still new at this chat thing, but code is posted. when i run it against sym([1, 2, 3], [5, 2, 1, 4]); i get [3, 4, 5] instead of [3, 5, 4]
Nic Galluzzo
@ngalluzzo
Aug 01 2015 19:28
o…m….g
I just finally passed symmetric difference
holy s(*#$ my heart skipped a beat lol
Vlad Zamfirescu
@vzamfirescu
Aug 01 2015 19:29
@ngalluzzo Congrats! :)
Melissa Yip
@su6a12
Aug 01 2015 19:29
@ngalluzzo awesome! any advice?
Nic Galluzzo
@ngalluzzo
Aug 01 2015 19:29
thanks dude :)
@su6a12 I went the reduce() route
Vlad Zamfirescu
@vzamfirescu
Aug 01 2015 19:30
@ngalluzzo reduce and then chained filters within it?
Nic Galluzzo
@ngalluzzo
Aug 01 2015 19:31
yes sir!
I was still getting some duplicates at the end so my end return is still a filter hah
could definitely optimize this a bit
Vlad Zamfirescu
@vzamfirescu
Aug 01 2015 19:31
@ngalluzzo It's quite a struggle to get it right using functional programming so congrats on that!
Melissa Yip
@su6a12
Aug 01 2015 19:31
@ngalluzzo thanks, i'll try that approach
Nic Galluzzo
@ngalluzzo
Aug 01 2015 19:32
@vzamfirescu thanks! I got to this bonfire over a month ago and was stumped on it for a week. From that point I decided to re-do every bonfire with a functional programming approach
cblupodev
@cblupodev
Aug 01 2015 19:35
adf
Am I supposed to respond with my local time or am I simply reformating the ISO time given to me? It's confusing because the JSON properties are different than that example ISO string
Nic Galluzzo
@ngalluzzo
Aug 01 2015 19:38
pretty sure it’ll spit an ISO string at you and you need to respond with hour minutes and seconds
cblupodev
@cblupodev
Aug 01 2015 19:38
@ngalluzzo hours and minutes pulled from the ISO string?
Nic Galluzzo
@ngalluzzo
Aug 01 2015 19:39
yup
cblupodev
@cblupodev
Aug 01 2015 19:39
@ngalluzzo Right. That makes sense. The instructions need an update to the ISO string and JSON properties match. Thanks
Brock Hayes
@brockson007
Aug 01 2015 20:01
blob
whats wrong with the code?
nevermind
Kolloom
@Kolloom
Aug 01 2015 20:07

Hi i'm doing bonfire Where art thou

source = { last: 'Capulet' };

how do i access the value of last without source['last'] or source.last

im not sure if last is the only key to be marched in this bonfire.
Steven Parker
@Philosophist
Aug 01 2015 20:08
Make a Person. I've tried a few things but all I get is "bob.getFirstName is not a function"
 var Person = function(firstAndLast) {
  var arr = firstAndLast.split(' ');
  this.getFirstName = arr[0];
  this.getLastName = arr[1];
  return firstAndLast;
};
  Person.prototype.setFirstName = function (first){this.getFirstName = first;};
  Person.prototype.setLastName = function (last){this.getLastName = last;};
  Person.prototype.getFullName = function (){
    var str = arr[0] + ' ' + arr[1];
    return str;
  };

var bob = new Person('Bob Ross');
bob.getFirstName();
Nic Galluzzo
@ngalluzzo
Aug 01 2015 20:09
get the key names with Object.keys(source) @Kolloom
then you can iterate through each key and get its value
@Philosophist you need to use methods instead of Prototypes for this bonfire
Kolloom
@Kolloom
Aug 01 2015 20:10
oh right source[Object.keys(source)] works
Nic Galluzzo
@ngalluzzo
Aug 01 2015 20:10
yup that’s right @Kolloom
Kolloom
@Kolloom
Aug 01 2015 20:10
thx @ngalluzzo
Nic Galluzzo
@ngalluzzo
Aug 01 2015 20:10
@Philosophist method: this.getFullName = function() { // code}
Franco Zapata
@Francozt01
Aug 01 2015 20:11
@brockson007 have you already fixed the problem with CSS?
Steven Parker
@Philosophist
Aug 01 2015 20:11
@ngalluzzo Here's what it looked like when I thought I was doing that. Same result.
var Person = function(firstAndLast) {
  var arr = firstAndLast.split(' ');
  this.getFirstName = arr[0];
  this.getLastName = arr[1];
  this.setFirstName = function (first){this.getFirstName = first;};
  this.setLastName = function (last){this.getLastName = last;};
  this.getFullName = function (){
    var str = arr[0] + ' ' + arr[1];
    return str;
  };
  return firstAndLast;
};

var bob = new Person('Bob Ross');
bob.getFirstName();
Franco Zapata
@Francozt01
Aug 01 2015 20:12
http://www.freecodecamp.com/challenges/bonfire-title-case-a-sentence any idea of how to do this cuz i already returned IMALTP but the other string don't work
Brock Hayes
@brockson007
Aug 01 2015 20:12

@Francozt01 here's where i'm at <link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>

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

h2 {
font-family: Lobster, Monospace;
}

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

!important: <style> .urgently-red { color: red !important; }

</style>

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

<p class='red-text'>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class='red-text'>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

Nic Galluzzo
@ngalluzzo
Aug 01 2015 20:13
@Philosophist this.getFirstName needs to be a function it can’t be a variable definition
so you can make it return arr[0] instead
Franco Zapata
@Francozt01
Aug 01 2015 20:16
@brockson007 inside the Style tags in ur CSS create ---> .blue-text { color:blue; } and .urgently-red { color:red !important; }
@brockson007 add those 2 classes inside the <style> </style>
Brock Hayes
@brockson007
Aug 01 2015 20:17
ok
Steven Parker
@Philosophist
Aug 01 2015 20:17

```
var Person = function(firstAndLast) {
var arr = firstAndLast.split(' ');
this.getFirstName = function (){return arr[0];};
this.getLastName = function (){return arr1;};
this.setFirstName = function (first){this.getFirstName = first;};
this.setLastName = function (last){this.getLastName = last;};
this.getFullName = function (){
var str = arr[0] + ' ' + arr1;
return str;
};
return firstAndLast;
};

var bob = new Person('Bob Ross');
bob.getFirstName();

``` @ngalluzzo Better? Still same issue saying bob.getFullName is not a function.

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

var bob = new Person('Bob Ross');
bob.getFirstName();
Brock Hayes
@brockson007
Aug 01 2015 20:19
@Francozt01 Thanks! I got stuck for a bit there :smile:
Nic Galluzzo
@ngalluzzo
Aug 01 2015 20:19
says setFullName is not a function @Philosophist
which you are missing
Steven Parker
@Philosophist
Aug 01 2015 20:19
@ngalluzzo Right... just caught it. Thanks!
Nic Galluzzo
@ngalluzzo
Aug 01 2015 20:20
any time
Franco Zapata
@Francozt01
Aug 01 2015 20:23
@brockson007 worked?
Brock Hayes
@brockson007
Aug 01 2015 20:23
@Francozt01 Yes indeed!
Franco Zapata
@Francozt01
Aug 01 2015 20:26
@brockson007 if you add 2 classes to the same element, and each have a different color for the element, you can choose which class is going to be applying its color by using " !important " in one of them .class1 { color:red !important; } .class2 { color:red; }
@brockson007 color :blue; ** lol
Brock Hayes
@brockson007
Aug 01 2015 20:27
@Francozt01 gotcha
@Francozt01 the !important emphasizes the color to be used
Franco Zapata
@Francozt01
Aug 01 2015 20:28
exactly!
Brock Hayes
@brockson007
Aug 01 2015 20:29
@Francozt01 I appreciate your helpfullness!
Franco Zapata
@Francozt01
Aug 01 2015 20:29
@brockson007 np we have to help each other
have a good day
Brock Hayes
@brockson007
Aug 01 2015 20:30
@Francozt01 You too
Steven Parker
@Philosophist
Aug 01 2015 20:31
@ngalluzzo Challenge completed!
Nic Galluzzo
@ngalluzzo
Aug 01 2015 20:32
nice, congrats!
Brock Hayes
@brockson007
Aug 01 2015 20:32
@Philosophist Good job!
Kolloom
@Kolloom
Aug 01 2015 20:32
Can anyone looks at my code? http://repl.it/zkm/1
Eude Lesperance
@lkeude96
Aug 01 2015 20:32
Does anyone know how I could transfer my credits to beta?
Nic Galluzzo
@ngalluzzo
Aug 01 2015 20:32
can’t @lkeude96
Kolloom
@Kolloom
Aug 01 2015 20:32
I have no idea why the output is like that
Eude Lesperance
@lkeude96
Aug 01 2015 20:32
:(
Kolloom
@Kolloom
Aug 01 2015 20:33
@lkeude96 i just watched the satureday stream, the core devs said that when beta is officially out the credit will merge with the current database.
Brock Hayes
@brockson007
Aug 01 2015 20:34
@Kolloom Wish I could help, but i'm still working on basic HTML
Nnxoxo
@Nnxoxo
Aug 01 2015 20:35
guys, watched stream today and discovered http://beta.freecodecamp.com/. So, the question is... Is it worth to register there?
Kolloom
@Kolloom
Aug 01 2015 20:35
@brockson007 i appreciate your effort :)
Brock Hayes
@brockson007
Aug 01 2015 20:37
@Kolloom I just started today, and i'm almost halfway through HTML :clap:
Nic Galluzzo
@ngalluzzo
Aug 01 2015 20:38
@Kolloom it’s because you’re ouptitting it with a string so it’s being parsed
try logging just result
outputting*
Kolloom
@Kolloom
Aug 01 2015 20:40
@ngalluzzo that's weird, what's being parsed though?
Nic Galluzzo
@ngalluzzo
Aug 01 2015 20:40
well it’s trying to parse an object as text
Justin Scoggin
@jscogg
Aug 01 2015 20:40

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

function mutation(arr) {
  if (arr[0].indexOf(arr[1])) {
    return true;
  } else {
    return false;
  }
}

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

Am I headed in the right direction here?

Nic Galluzzo
@ngalluzzo
Aug 01 2015 20:40
if you did… result.last or result.first (like an actual property) it would parse that property’s text
Kolloom
@Kolloom
Aug 01 2015 20:41
isn't that an object inside an array?
Nic Galluzzo
@ngalluzzo
Aug 01 2015 20:42
you only have 1 single object.
not an array
sorry, it is an array
an object in an array
Kolloom
@Kolloom
Aug 01 2015 20:43
so the behavior changes?
Nic Galluzzo
@ngalluzzo
Aug 01 2015 20:43
repl_it_-_JavaScript.png
result0.last is a string so you’ll see it properly within a String
because you added ‘Result’ + you’re turning the whole line into a string
Kolloom
@Kolloom
Aug 01 2015 20:46
that's quite unexpected
@jscogg look at the input['hello', 'hey']: arr[0] would get 'hello', 'arr[1] would get 'hey', not individual characters
Jakob Dahl
@saadanerdetbare
Aug 01 2015 20:48
@jscogg you have to split the second string and check for the letters individually. They can come in any order
Justin Scoggin
@jscogg
Aug 01 2015 20:49
@saadanerdetbare but I don't need to split the first string, right?
Jakob Dahl
@saadanerdetbare
Aug 01 2015 20:49
nope
Justin Scoggin
@jscogg
Aug 01 2015 20:49
alright.... i'll giver 'er a go
Kolloom
@Kolloom
Aug 01 2015 20:50
i did split both, snap!
Kolloom
@Kolloom
Aug 01 2015 21:51
is the bonfire Pig Latin require all the consonants to be moved to the most right until the word begins with an vowel?
Justin Scoggin
@jscogg
Aug 01 2015 21:52
Meh... still working on "Mutations". Here's where I am:
function mutation(arr) {
  var toCheck = arr[1].split('');
  for (var i = 0; i < toCheck.length; i++) {
    if (arr[0].indexOf(toCheck[1]) > -1) {
      var checkResult = "found";
    } else {
      var checkResult = "not found";
      break;
    }
  }
  if (checkResult === "not found") {
    return false;
  } else {
    return true;
  }
}

mutation(['hello', 'hey']);
Kolloom
@Kolloom
Aug 01 2015 21:54
glove, first word consonant, move it to the back ==> loveg
loveg, first word consonant, move it to the back ==> ovegl
ovegl,first word vowel, add ay to the end ==> oveglay ?
@jscogg you made a loop with i and didn't use i at all
check if toCheck[i] is in arr
Justin Scoggin
@jscogg
Aug 01 2015 21:58
Woops! Changed it, and it's still failing. :worried:
Kolloom
@Kolloom
Aug 01 2015 22:00
?? how
you didn't check the different case
For example, ['hello', 'Hello'], should return true because all of the letters in the second string are present in the first, !!!!!ignoring case!!!!!.
also the variable checkResult is not necessary, just use return statement under the first if loop
Kolloom
@Kolloom
Aug 01 2015 22:06
good job on the > -1, I have been using !== -1 up to now, never though of that :)
Justin Scoggin
@jscogg
Aug 01 2015 22:09
alright so I have to throw in .toLowerCase() somewhere... are you saying that the first loop should just say return true; and then return false;?
i m trying to add a weather icon. please help
Kolloom
@Kolloom
Aug 01 2015 22:12
@jscogg yup
Fabio Mello
@makall
Aug 01 2015 22:15
@ydjjabt hi, I think on #skyImage you need to quote the "<img..." statement
John Chau
@ydjjabt
Aug 01 2015 22:17
@makall u mean like this $("#skyImage").html(<img src='http://openweathermap.org/img/w/'+ result.weather[0].icon +'.png'></img>)
Alanna M
@weirdhockeygirl16
Aug 01 2015 22:17
what does % mean in java
Fabio Mello
@makall
Aug 01 2015 22:19
@ydjjabt yep, think about which part is static and which part is dynamicy, i mean, between the "<img" and the plus sign, you need the double quote and after the second plus sign and after the </img> you will need to close it with double quotes also
Justin Scoggin
@jscogg
Aug 01 2015 22:19

Here's my code now on "Mutations":

function mutation(arr) {
  var toCheck = arr[1].toLowerCase().split('');
  for (i = 0; i < toCheck.length; i++) {
    if (arr[0].indexOf(toCheck[i]) > -1) {
      return true;
    } else {
      return false;
    }
  }
}

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

Still not passing... I feel like I'm sooo close...

Fabio Mello
@makall
Aug 01 2015 22:19
@weirdhockeygirl16 you will get the remaining part of a division with %. 5/2 = 2; 5%2 = 1;
Mary
@marycontrary
Aug 01 2015 22:19
if(str.substr(0,2) !== /[aeiou]/g){
I'm obviously not doing my regexp correct, can someone direct me on what I need to do?
Fabio Mello
@makall
Aug 01 2015 22:21
@marycontrary are you trying to check if the first two characters of the str are vowels?
Kolloom
@Kolloom
Aug 01 2015 22:22
@jscogg oh yeah i forgot that return would break the loop so you only iterate once
Mary
@marycontrary
Aug 01 2015 22:22
@makall Yes.
Justin Scoggin
@jscogg
Aug 01 2015 22:22
@Kolloom So how do I keep it from breaking until it finds a false value? The way I had it?
Fabio Mello
@makall
Aug 01 2015 22:24
@marycontrary I think you should try /[aeiou]{2}/ instead, it will check if there is two vowels there. I not good on regex but that "g" sounds weird there
Alanna M
@weirdhockeygirl16
Aug 01 2015 22:24
@makall Thanks!
Fabio Mello
@makall
Aug 01 2015 22:24
=)
Mary
@marycontrary
Aug 01 2015 22:24
@makall Thanks! I will try that.
Kolloom
@Kolloom
Aug 01 2015 22:25
@jscogg you can delete the return true line and place it outside the for loop
so when the condition is true it does nothing and continues to next iteration
Justin Scoggin
@jscogg
Aug 01 2015 22:28
That makes sense.
Kolloom
@Kolloom
Aug 01 2015 22:28
if the loop never met the condition the loop is over so you have to return true outside that
Justin Scoggin
@jscogg
Aug 01 2015 22:29
RIght, I got you. Is there another way to iterate without having to have that first part empty though?
Kolloom
@Kolloom
Aug 01 2015 22:29
there is
make the loop condition only for the false case
if (arr[0].indexOf(toCheck[i]) === -1) {
        return false;
    }
something like this
Justin Scoggin
@jscogg
Aug 01 2015 22:32
You have to tag the else with that, right?
Kolloom
@Kolloom
Aug 01 2015 22:33
the else is not necessary
Justin Scoggin
@jscogg
Aug 01 2015 22:33
gotcha
Kolloom
@Kolloom
Aug 01 2015 22:33
if the condition is not met it simply goes to the next iteration
Justin Scoggin
@jscogg
Aug 01 2015 22:36
That would have been cleaner... now I have a wonky solution on my profile page :laughing:
Robert
@rc242
Aug 01 2015 22:37
heyo.
Jakob Dahl
@saadanerdetbare
Aug 01 2015 22:37
@jscogg i think many of us have that :laughing:
Justin Scoggin
@jscogg
Aug 01 2015 22:37
:D
Rodrigo Fierro R.
@rodrigofierro
Aug 01 2015 22:38
Any debian users?
Kolloom
@Kolloom
Aug 01 2015 22:38
@jscogg congratulations
Justin Scoggin
@jscogg
Aug 01 2015 22:38
Thanks for the help @Kolloom
Kolloom
@Kolloom
Aug 01 2015 22:38
no problem :)
Jeff Bynum
@bynumjj
Aug 01 2015 22:44
Seek and Destroy help? -- My "remove" function stops after the first iteration of "i". Is there an issue with running a "for" loop through ".filter?"
Screen Shot 2015-08-01 at 3.38.19 PM.png
Ingrid
@voodoobettie
Aug 01 2015 22:49
I'm working on the string reversal bonfire and my code only passes the first two tests, but not the ones with spaces - can anyone give me some advice on how to fix it?
(Apparently I can't embed that)
Jakob Dahl
@saadanerdetbare
Aug 01 2015 22:54
@voodoobettie its much easier to use http://repl.it/ for sending snippets of code like that
repl is cool
Fabio Mello
@makall
Aug 01 2015 22:54
@bynumjj I think that will be good you rethink your code doing baby steps, I mean, check if your function is receiving the right parameters first, then you pass then to the next function. I don't know this challenge, so I'm not sure if it is expected to use "arguments" to get the parameters. I'm saying that because there is another and easy way to do that.
Jakob Dahl
@saadanerdetbare
Aug 01 2015 22:58
@voodoobettie i've made a stub here but theres a bit more to do on the regex http://repl.it/zld/1
Ingrid
@voodoobettie
Aug 01 2015 23:01
Okay I will try that. I just signed up to codepen to post that haha. Never mind.
Jakob Dahl
@saadanerdetbare
Aug 01 2015 23:02
@voodoobettie you need codepen later on
Ingrid
@voodoobettie
Aug 01 2015 23:02
Ah ok. RegEx to the rescue! Thanks for the tip!
@saadanerdetbare Thanks!
Jakob Dahl
@saadanerdetbare
Aug 01 2015 23:02
yw
Luis Felipe López G.
@luishendrix92
Aug 01 2015 23:03
Would anybody be kind enough to send me (via private message) a list of topics or references I should read in order to complete the bonfires before diving into them? (For example, for palindromes in Coderbyte.com I had to do my research on recursion and String.prototype.replace(regex))
Jakob Dahl
@saadanerdetbare
Aug 01 2015 23:06
@luishendrix92 i often google: javascript <function i need> mdn for finding the reference on mozilla dev network and then i use stackowerflow a lot
Luis Felipe López G.
@luishendrix92
Aug 01 2015 23:08
@saadanerdetbare I usually go to youtube and the W3C. The good thing about MDN is that the documentation is huge and you can actually see what arguments does a function accepts and what value is returned.
Jakob Dahl
@saadanerdetbare
Aug 01 2015 23:08
msdn has i good reference too
i don't know if there is such a list
SojournerOctocat
@SojournerOctocat
Aug 01 2015 23:14
Working on Bonfire Search and Replace. The code below is supposed to indicate whether the first letter of the search text is uppercase in the string to be searched. Instead, the console just prints lowercase. The console doesn't even print the results of the strFindTextFirstLetter variable. What gives?

var str = "A quick brown fox Jumped over the lazy dog";
var strFindText ="jumped";
var strReplaceText = "leaped";

var strFindTextFirstLetter = str.charAt(str.indexOf(strFindText));


if (strFindTextFirstLetter == strFindTextFirstLetter.toUpperCase) {
    console.log("uppercase " + strFindTextFirstLetter);
} else {
    console.log("lowercase " + strFindTextFirstLetter);
}
Okay, so I see where I forgot to add the empty parentheses, as in toUpperCase(). I added those and it does print uppercase or lowercase. However, if the answer is uppercase, it does not print the strFindTextFirstLetter variable in the console. It does do it for lowercase.
Luis Felipe López G.
@luishendrix92
Aug 01 2015 23:20

@SojournerOctocat I tried using a regex:

var str = "A quick brown fox Jumped over the lazy dog",
    strFindText ="jumped",
    strReplaceText = "leaped",
    matchesList = str.match(/\bjumped\b/ig);

str.replace(/\bjumped\b/ig, "leaped");

console.log(str);

But I would also want to do this: if the matched word "jumped" starts with a capital J, replace with Leaped instead of leaped.

Ignore my declarations of strFindText and strReplaceText, they're innecessary now...
also ignore matchesList, err I'm a mess
SojournerOctocat
@SojournerOctocat
Aug 01 2015 23:22

Thanks for the that, but I'm still confused as to why the console isn't printing that variable, @luishendrix92. It doesn't make sense.

For the code to pass all the tests, I would need to use variables in place of /\bjumped/b/ig.

Reggie
@Reggie01
Aug 01 2015 23:23
@SojournerOctocat If the string is uppercase in str and your variable is strFindText === "jumped". Then it does'nt exist in the string. "Jumped" != "jumped"
Ingrid
@voodoobettie
Aug 01 2015 23:23
Question: Can someone explain why you'd put ([regex], "g") at the end of a regex instead of [regex]/g?
SojournerOctocat
@SojournerOctocat
Aug 01 2015 23:24
@Reggie01 But the variable doesn't reference strFindText. strFindTextFirstLetter references str.
Jakob Dahl
@saadanerdetbare
Aug 01 2015 23:24
@SojournerOctocat @luishendrix92 you need to look at the arguments that is coming into the function: this could be one way of doing that
function replace(str, before, after) {

    if(before.split("")[0] === before.split("")[0].toUpperCase){

    }

 return str;
}

replace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
Reggie
@Reggie01
Aug 01 2015 23:25
@SojournerOctocat ''' var strFindTextFirstLetter = str.charAt(str.indexOf(strFindText)); '''
@SojournerOctocat var strFindTextFirstLetter = str.charAt(str.indexOf(strFindText));
SojournerOctocat
@SojournerOctocat
Aug 01 2015 23:26
@Reggie01 Thanks! I didn't see that!
Robert
@rc242
Aug 01 2015 23:27
about to have the ugliest quote generator.. evah. :smirk_cat:
Luis Felipe López G.
@luishendrix92
Aug 01 2015 23:28

I tried this and it works haha:

var str = "A quick brown fox Jumped over the lazy dog"

str = str.replace(/\bjumped\b/ig, "leaped");

console.log(str);
// Consoles --> "A quick brown fox leaped over the lazy dog"

I used the regex because it ignores capitalization and makes it simpler to write.

SojournerOctocat
@SojournerOctocat
Aug 01 2015 23:28
@saadanerdetbare Actually, it's the string to be searched that needs the lowercase/uppercase test run on it. But maybe I can use your suggestion to do that.
cblupodev
@cblupodev
Aug 01 2015 23:29

Working on the Express waypoint
asdf
asdf

var express = require("express");
var app = express();

app.get('/home', function(req, res) {
    res.end(app.use(express.static(process.argv[3].join(__dirname, 'public'))));
}).listen(process.argv[2]);

Why am I getting that error?

SojournerOctocat
@SojournerOctocat
Aug 01 2015 23:29
@luishendrix92 That's only going to work for one test. It won't pass the other tests.
Luis Felipe López G.
@luishendrix92
Aug 01 2015 23:32
@SojournerOctocat Aww what a shame, would have to finish the damned jQuery lessons to check on those bonfires and see what the fuzz is all about. Hope you solve it :)
Jakob Dahl
@saadanerdetbare
Aug 01 2015 23:33
@SojournerOctocat the before word has to exist in the string to search so it is the before word that is important
John Chau
@ydjjabt
Aug 01 2015 23:35
$.get('http://ipinfo.io',
 function(data,status,xhr){
  console.log(xhr)

},"json")
SojournerOctocat
@SojournerOctocat
Aug 01 2015 23:35
@saadanerdetbare But it's word in the search string that's going to uppercase or lowercase. If the word in the search string is uppercase, then the after word has to be uppercase. The before word is probably going to always be lowercase.
John Chau
@ydjjabt
Aug 01 2015 23:35

```
$.get('http://ipinfo.io',
function(data,status,xhr){
console.log(data)

},"json")
``` how come the data is not output

not output as JSOn object
SojournerOctocat
@SojournerOctocat
Aug 01 2015 23:36
@saadanerdetbare NOTE: Preserve the case of the original word when you are replacing it. For example if you mean to replace the word 'Book' with the word 'dog', it should be replaced as 'Dog'
Jakob Dahl
@saadanerdetbare
Aug 01 2015 23:37
@SojournerOctocat precisely, so the beforeword will in that case be: Book
John Chau
@ydjjabt
Aug 01 2015 23:38
got it
SojournerOctocat
@SojournerOctocat
Aug 01 2015 23:39
@saadanerdetbare No, the before word will be book. The word in the string will be Book.
Luis Felipe López G.
@luishendrix92
Aug 01 2015 23:42
Oh I got it: str.replace(/jumped/gi, function capitalize(word){return word[0].toUpperCase();}); I got the info from W3C on String.prototype.replace()
Steven Parker
@Philosophist
Aug 01 2015 23:42
Map the Debris.png
I'm confused about the output format that this challenge is asking for.
Luis Felipe López G.
@luishendrix92
Aug 01 2015 23:43
I mean word[0].toUpperCase + word.slice(1)
Jakob Dahl
@saadanerdetbare
Aug 01 2015 23:44
@SojournerOctocat let's just leave it at where we settle on the fact that i've solvet it and you've not
Moisés Man
@moigithub
Aug 01 2015 23:45
@Philosophist copy paste the text of the test case here... it start with expect(orbital
Reggie
@Reggie01
Aug 01 2015 23:45
@cblupodev have not made it to express problems but your error looks like its looking for a path at "/" but your path is "/home"
Steven Parker
@Philosophist
Aug 01 2015 23:46
function orbitalPeriod(arr) {
  var GM = 398600.4418;
  var earthRadius = 6367.4447;
  var newArr = [];
  for(var i = 0; i < arguments.length; i++){
    newArr.push([arr[0].name, Math.round(2*Math.PI*Math.pow(Math.pow(earthRadius+arr[0].avgAlt, 3)/GM, 1/2))]);
  }
  return newArr;
}

orbitalPeriod([{name : "sputkin", avgAlt : 35873.5553}]);
SojournerOctocat
@SojournerOctocat
Aug 01 2015 23:46
@saadanerdetbare Well, that doesn't make sense to me, but I haven't solved it yet, much less looked at the tests, so I'll take your word for it.
Moisés Man
@moigithub
Aug 01 2015 23:46
the test case too.. bottom left side @Philosophist (one of the failing test )
Steven Parker
@Philosophist
Aug 01 2015 23:47
expect(orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}])).to.eqls([{name : "iss", orbitalPeriod: 5557}, {name: "hubble", orbitalPeriod: 5734}, {name: "moon", orbitalPeriod: 2377399}]);expected [ [ 'iss', 5557 ] ] to deeply equal [ Array(3) ]
Moisés Man
@moigithub
Aug 01 2015 23:48
ok.. now lets split that..
Jeff Bynum
@bynumjj
Aug 01 2015 23:49
@makall Thanks, Makall. The goal of the assignment is to use Arguments Object and Array.filter. The argument statement works fine, and the filter returns the correct value for the first pass of i, then it stops iterating. My question is whether there’s a trick to using for loops in a filter.
Steven Parker
@Philosophist
Aug 01 2015 23:49
@moigithub You mean to focus on [{name : "iss", orbitalPeriod: 5557}, {name: "hubble", orbitalPeriod: 5734}, {name: "moon", orbitalPeriod: 2377399}]
?
Moisés Man
@moigithub
Aug 01 2015 23:49
expect(
orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}])
).to.eqls(
[{name : "iss", orbitalPeriod: 5557}, {name: "hubble", orbitalPeriod: 5734}, {name: "moon", orbitalPeriod: 2377399}]
);
expected [ [ 'iss', 5557 ] ]
Steven Parker
@Philosophist
Aug 01 2015 23:51
function orbitalPeriod(arr) {
  var GM = 398600.4418;
  var earthRadius = 6367.4447;
  var newArr = [];
  for(var i = 0; i < arguments.length; i++){
    newArr.push([{name: arr[0].name, orbitalPeriod: Math.round(2*Math.PI*Math.pow(Math.pow(earthRadius+arr[0].avgAlt, 3)/GM, 1/2))}]);
  }
  return newArr;
}

orbitalPeriod([{name : "sputkin", avgAlt : 35873.5553}]);
cblupodev
@cblupodev
Aug 01 2015 23:51
@Reggie01 Figured it out. process.argv[3] indeed does not point to index.html. It points to the very file I'm running with. Thanks tho. Trying to submit a report
Moisés Man
@moigithub
Aug 01 2015 23:52
"the tester" call ur function and send some data to it... (first n second line)
then evaluate and try to compare YOUR result with the CORRECT result
and finally expect your result [ 'iss', 5557 ] is equal something
Reggie
@Reggie01
Aug 01 2015 23:52
@cblupodev ok, glad you figured it out
Steven Parker
@Philosophist
Aug 01 2015 23:53
expect(orbitalPeriod([{name : "sputkin", avgAlt : 35873.5553}])).to.eqls([{name: "sputkin", orbitalPeriod: 86400}]);expected [ Array(1) ] to deeply equal [ Array(1) ]
function orbitalPeriod(arr) {
  var GM = 398600.4418;
  var earthRadius = 6367.4447;
  var newArr = [];
  for(var i = 0; i < arguments.length; i++){
    newArr.push({name: arr[0].name, orbitalPeriod: Math.round(2*Math.PI*Math.pow(Math.pow(earthRadius+arr[0].avgAlt, 3)/GM, 1/2))});
  }
  return newArr;
}

orbitalPeriod([{name : "sputkin", avgAlt : 35873.5553}]);
Ok this fixed the first test case. Removed the outer bracket in push function

expect
(orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}])).
to.eqls
([{name : "iss", orbitalPeriod: 5557}, {name: "hubble", orbitalPeriod: 5734}, {name: "moon", orbitalPeriod: 2377399}]);

expected [ Array(1) ] to deeply equal [ Array(3) ]

Alanna M
@weirdhockeygirl16
Aug 01 2015 23:57
var perimiterBox = function(length, width) {
return length + length + width + width;

};
perimiterBox(8,7)
whats wrong with this?
Steven Parker
@Philosophist
Aug 01 2015 23:58
Ahh, I think I see it
Kolloom
@Kolloom
Aug 01 2015 23:59
@weirdhockeygirl16 the function runs perfectly fine in repl.it
Alanna M
@weirdhockeygirl16
Aug 01 2015 23:59
its not in codecademy @Kolloom