These are chat archives for FreeCodeCamp/Help

9th
Sep 2015
Mateja Trifunovski
@Matko95
Sep 09 2015 00:00
yeah, it logs an Object
Rory Smith
@alanbuchanan
Sep 09 2015 00:01
so how do you refer to object values?
Mateja Trifunovski
@Matko95
Sep 09 2015 00:02
twitch.link etc?
jhois
@jhois
Sep 09 2015 00:03
what does ::after and ::before do in html?
I feel like there is a lot of info not taught for the first front end development zipline
Mateja Trifunovski
@Matko95
Sep 09 2015 00:04
Oh i realize now
@alanbuchanan @awesomeaniruddh Thanks alot guys :D
CamperBot
@camperbot
Sep 09 2015 00:04
matko95 sends brownie points to @alanbuchanan and @awesomeaniruddh :sparkles: :thumbsup: :sparkles:
:star: 278 | @alanbuchanan | http://www.freecodecamp.com/alanbuchanan
:star: 378 | @awesomeaniruddh | http://www.freecodecamp.com/awesomeaniruddh
Thomas Vaeth
@thomasvaeth
Sep 09 2015 00:06
Ugh. I need to start the Twitch project next since the reorganization of the site. I'm not looking forward to it.
Mateja Trifunovski
@Matko95
Sep 09 2015 00:08
I kinda stopped doing projects when i got to him :D but i'm back willing to finish it
Aniruddh Agarwal
@anrddh
Sep 09 2015 00:08
It's actually pretty easy :P
Mateja Trifunovski
@Matko95
Sep 09 2015 00:08
But yeah it's easy when someone explains it
Aniruddh Agarwal
@anrddh
Sep 09 2015 00:08
The search is difficult to implement I guess
But isn't it now under the Angular projects?
Rory Smith
@alanbuchanan
Sep 09 2015 00:13
http://lloiser.github.io/jquery-searcher/ this is good for search functionality, i used it in my Twitch project (but i assume angular's filter probably outdoes anything jquery can do)
Aniruddh Agarwal
@anrddh
Sep 09 2015 00:15
Angular's a full-blown framework, while jQuery is a puny library :P
But they both have their uses
Rory Smith
@alanbuchanan
Sep 09 2015 00:16
poor jquery :crying_cat_face:
max77p
@max77p
Sep 09 2015 00:23
can someone give me a hint to the first bonfire?
Mukul Patel
@Mukul215
Sep 09 2015 00:26
Hi can someone help me figure out why this isn't working?
function findLongestWord(str) {
  var newArray = str.split('');
  var len = newArray.length;
  var returnLength;

  for(var i=0;i<len;i++) {
    if (newArray[i].length >= newArray[i-1].length) {
      returnLength = newArray[i].length;
    }
  }

  return returnLength;
}
Rory Smith
@alanbuchanan
Sep 09 2015 00:26
@max77p bonfire meet bonfire
Aniruddh Agarwal
@anrddh
Sep 09 2015 00:28
@Mukul215 first of all, you probably want to split with a space
also, set returnLength to 0 can compare newArray[i].length with returnLength
Mukul Patel
@Mukul215
Sep 09 2015 00:29
Ok, that makes sense. However, I still get the error Cannot read property 'length' of undefined
Mateja Trifunovski
@Matko95
Sep 09 2015 00:30
Where can i find a online twitch streamer, for testing purposes?
Rory Smith
@alanbuchanan
Sep 09 2015 00:30
@max77p there's a bit of a trick to that one
Barent
@Barent
Sep 09 2015 00:31
am on the "Bonefire: Title Case a Sentence" and I wrote this and it returns the result as the section instructed, but the tests are still failing. Any advice would be greatly appreciated!
max77p
@max77p
Sep 09 2015 00:31
@alanbuchanan reverseString('hello');
var myArray=str.split();
reverseString=myArray.reverse();
Barent
@Barent
Sep 09 2015 00:31

function titleCase(str) {
var makeLowerCase = str.toLowerCase();
var stringToArray = makeLowerCase.split([" "]);
var finishedArray = [];

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

var firstLetter = stringToArray[i].charAt(0);
var upperCase = stringToArray[i].charAt(0).toUpperCase(firstLetter);
var upperCaseWord = stringToArray[i].replace([firstLetter], [upperCase]);
finishedArray += " " + upperCaseWord;

}

return finishedArray;
}

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

Apologies for splitting up the code
max77p
@max77p
Sep 09 2015 00:31
i know this is wrong, but how do i get the reversestring to get in the array
Terrence
@terrencechambers
Sep 09 2015 00:32
split the string to get into an array
max77p
@max77p
Sep 09 2015 00:32
@bellyoffire do i use reversestring.split()?
Terrence
@terrencechambers
Sep 09 2015 00:32
str.split(' ') puts it into an array and splits it out into words
what ever your string name is is what you use
you could do this str.toLowerCase().split(' ');
Rory Smith
@alanbuchanan
Sep 09 2015 00:33
@max77p you're kind of close. have you got the whole thing inside a function?
travisdh
@travisdh
Sep 09 2015 00:34
hey guys, i am fairly new to this and have a quick question about Waypoint: Add Font Awesome Icons to our Buttons section problem.
max77p
@max77p
Sep 09 2015 00:34
@alanbuchanan ahhh ic, it should be inside the function
Chin Loong Goh
@chinloong93
Sep 09 2015 00:34
How do you print to the console on Bonfire?
Can anyone help me out?
Terrence
@terrencechambers
Sep 09 2015 00:35
just return something and it will go to the console, otherwise console.log()
@travisdh what is the problem
Chin Loong Goh
@chinloong93
Sep 09 2015 00:36
thanks!
CamperBot
@camperbot
Sep 09 2015 00:36
if you want to thank someone, put an @ before their name!
Chin Loong Goh
@chinloong93
Sep 09 2015 00:37
@bellyoffire thank you!
CamperBot
@camperbot
Sep 09 2015 00:37
chinloong93 sends brownie points to @bellyoffire :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for bellyoffire
max77p
@max77p
Sep 09 2015 00:38
@alanbuchanan woot thanks! i got it, i just needed to get it inside the function.
CamperBot
@camperbot
Sep 09 2015 00:38
max77p sends brownie points to @alanbuchanan :sparkles: :thumbsup: :sparkles:
:star: 280 | @alanbuchanan | http://www.freecodecamp.com/alanbuchanan
Rory Smith
@alanbuchanan
Sep 09 2015 00:39
@max77p :+1:
max77p
@max77p
Sep 09 2015 00:39

@alanbuchanan function reverseString(str) {
var myArray=str.split("");
str=myArray.reverse("");
str=myArray.join("");

return str;
}

reverseString('hello');

why do we have to put "" inside the bracket?
Aniruddh Agarwal
@anrddh
Sep 09 2015 00:39
No "" inside reverse bracket
DTing
@dting
Sep 09 2015 00:39
you should take a look at the docs
bf reverse
CamperBot
@camperbot
Sep 09 2015 00:39

:fire:Bonfire: Reverse a String :link:

function reverseString(str) {
  return str;
}

reverseString('hello');

Reverse the provided string.

more info:  bf details | bf links | hint

DTing
@dting
Sep 09 2015 00:39
bf links
Rory Smith
@alanbuchanan
Sep 09 2015 00:40
because it must have an argument, in this case an empty string @max77p (not reverse though)
Terrence
@terrencechambers
Sep 09 2015 00:40
@max77p you can do more than 1 function at a time by joining them with a .
max77p
@max77p
Sep 09 2015 00:40
@bellyoffire what do you mean? example please?
Aniruddh Agarwal
@anrddh
Sep 09 2015 00:41
@max77p split() takes a string as its argument. It splits the string it is called on based on the argument
Terrence
@terrencechambers
Sep 09 2015 00:41
var myArray=str.split(" ").reverse().join("");
Aniruddh Agarwal
@anrddh
Sep 09 2015 00:41
If you pass in "", that splits every character of the string
Harry Gill
@mygnu
Sep 09 2015 00:41
you can chain functions i.e variable.doSonething().doSomethingElse()
Aniruddh Agarwal
@anrddh
Sep 09 2015 00:42
If you pass in " ", it splits characters based on spaces
Same with join()
max77p
@max77p
Sep 09 2015 00:42
ahh ok, thanks @awesomeaniruddh @mygnu @bellyoffire
CamperBot
@camperbot
Sep 09 2015 00:42
max77p sends brownie points to @awesomeaniruddh and @mygnu and @bellyoffire :sparkles: :thumbsup: :sparkles:
:star: 249 | @bellyoffire | http://www.freecodecamp.com/bellyoffire
:star: 247 | @mygnu | http://www.freecodecamp.com/mygnu
:star: 380 | @awesomeaniruddh | http://www.freecodecamp.com/awesomeaniruddh
Rory Smith
@alanbuchanan
Sep 09 2015 00:46
@max77p also, if you take care to remember that split('').reverse().join('') is a way to reverse a string, it'll come in handy for later tasks
@Matko95 you asked about a 24/7 twitch stream http://www.twitch.tv/monstercat
Mateja Trifunovski
@Matko95
Sep 09 2015 00:49
@alanbuchanan thanks :)
Rory Smith
@alanbuchanan
Sep 09 2015 01:03
@Matko95 speaking of which, freecodecamp twitch just went online so you could even test with that :)
Mateja Trifunovski
@Matko95
Sep 09 2015 01:03
@alanbuchanan just seen that :D
it appeared in my console which is good
Rory Smith
@alanbuchanan
Sep 09 2015 01:04
working already? nice
Mrs Jones
@iamMrsjones
Sep 09 2015 01:04
hi
i am working on Waypoint: Learn how Script Tags and Document Ready Work
geting an error on "Unexpected identifier"
Rory Smith
@alanbuchanan
Sep 09 2015 01:06
@iamMrsjones can you post your code?
Mrs Jones
@iamMrsjones
Sep 09 2015 01:06

<script>
Add $(document).ready(function() {

};
</script>

<div class="container-fluid">
<h3 class="text-primary text-center">jQuery Playground</h3>
<div class="row">
<div class="col-xs-6">
<h4>#left-well</h4>
<div class="well" id="left-well">
<button class="btn btn-default target" id="target1">#target1</button>
<button class="btn btn-default target" id="target2">#target2</button>
<button class="btn btn-default target" id="target3">#target3</button>
</div>
</div>
<div class="col-xs-6">
<h4>#right-well</h4>
<div class="well" id="right-well">
<button class="btn btn-default target" id="target4">#target4</button>
<button class="btn btn-default target" id="target5">#target5</button>
<button class="btn btn-default target" id="target6">#target6</button>
</div>
</div>
</div>
</div>

here is the code
Rory Smith
@alanbuchanan
Sep 09 2015 01:08
@iamMrsjones you don't need to write 'Add'
and check your brackets
DavidThms
@DavidThms
Sep 09 2015 01:13
var myArray = [];
for(var i = 0; i < 4; i++){
  myArray.push(i);
}
Hello, can someone help me make the myArray variable equal to [0,1,2,3,4]. I'm kind of stuck
Rex Schrader
@SaintPeter
Sep 09 2015 01:15
@DavidThms You need to have it be <= 4 or < 5, otherwise it stops too soon
DavidThms
@DavidThms
Sep 09 2015 01:17
@SaintPeter oh wow, Thanks
CamperBot
@camperbot
Sep 09 2015 01:17
davidthms sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 551 | @saintpeter | http://www.freecodecamp.com/saintpeter
Rex Schrader
@SaintPeter
Sep 09 2015 01:18
@DavidThms The thing to remember about for loops is that loop while the condition is TRUE. Just think about what the first number that makes the condition not true will be.
Wesley McCann
@Septimus
Sep 09 2015 01:20
@all Are you struggling with Bonfires? Then come watch us work through them on stream! Bonefire Office Hours with Briana
burySpot
@burySpot
Sep 09 2015 01:29
Hi guys
I'm having problems with some of the results of the Palindrome bonfire
Jose E. Pimentel
@jedpimentel
Sep 09 2015 01:32
@burySpot post your code :)
michaelpcampbell
@michaelpcampbell
Sep 09 2015 01:32

@michaelpcampbell
hey i need help with .pop()
http://freecodecamp.com/challenges/waypoint-manipulate-arrays-with-pop
//var numbers = [1,2,3];
//console.log(numbers); // logs [1,2,3]
//var removed = numbers.pop();
//console.log(numbers); // logs [1,2]
//console.log(removed); // logs 3

var myArray = ["John", 23, ["cat", 2]];
// Only change code below this line.

var removed = myArray // This should be ["cat", 2] and myArray should now be ["John", 23]

// Only change code above this line.
// We use this function to show you the value of your variable in your output box.
// You'll learn about functions soon.
(function(y, z){return 'myArray = ' + JSON.stringify(y) + ' & removed = ' + JSON.stringify(z);})(myArray, removed);

DTing
@dting
Sep 09 2015 01:33
@michaelpcampbell they want you to assign the value that is returned from calling myArray.pop() to the variable removed
burySpot
@burySpot
Sep 09 2015 01:33
function palindrome(str) {
  // Good luck!
  str2=str;
  var res=true;
  str2=str2.replace(/\W/g, '');
  str2=str2.toLowerCase();
  var array=str2.split();
  var num=array.length;
  for(var i=0;i<num/2;i++){
    if(array[i]!=array[num-1-i]){
      res=false;
    }
  }
 return res;
}



palindrome("not a palindrome");
michaelpcampbell
@michaelpcampbell
Sep 09 2015 01:33
how do i do that
burySpot
@burySpot
Sep 09 2015 01:33
it should return false, but it returns true again...
DTing
@dting
Sep 09 2015 01:33
@burySpot split needs a separator arguemnt
otherwise it returns the string that you are splitting as a single element
burySpot
@burySpot
Sep 09 2015 01:34
oh that's right, i'll test it again!
michaelpcampbell
@michaelpcampbell
Sep 09 2015 01:35
@dting how do i do that
DTing
@dting
Sep 09 2015 01:35
@michaelpcampbell
// Only change code below this line.
var removed = myArray // change this line
// Only change code above this line.
burySpot
@burySpot
Sep 09 2015 01:35
@michaelpcampbell you send your code like this (linebreak)(your code)(linebreak)
Jose E. Pimentel
@jedpimentel
Sep 09 2015 01:35
also, you can go ahead and return false; directly inside the if, instead of storing it in the result,
burySpot
@burySpot
Sep 09 2015 01:35
thanks for that tip too!
CamperBot
@camperbot
Sep 09 2015 01:36
if you want to thank someone, put an @ before their name!
burySpot
@burySpot
Sep 09 2015 01:36
thanks @jedpimentel @dting
CamperBot
@camperbot
Sep 09 2015 01:36
buryspot sends brownie points to @jedpimentel and @dting :sparkles: :thumbsup: :sparkles:
:star: 286 | @jedpimentel | http://www.freecodecamp.com/jedpimentel
:star: 1062 | @dting | http://www.freecodecamp.com/dting
coop512c
@coop512c
Sep 09 2015 01:37
Hey guys, I am not very sure what I am doing wrong on Waypoint 149. Here is my code that I entered:

function myFunction(){
var flip = Math.floor(Math.random() * (1 - 0 + 1)) + 0;
// Create an if-else statement here to return "heads" if flip is 0. Otherwise return "tails".

// Only change code below this line.
if (var flip === 0) {
return heads;
}

else (var flip > 0) {
return tails;

}
}
// Only change code above this line.
// We use this function to show you the value of your variable in your output box.
(function(){return myFunction();})();

Chocobowings
@chocobowings
Sep 09 2015 01:42
@coop512c You are missing double quotes...
@coop512c heads and tails are not variables
Richard Gottleber
@rgottleber
Sep 09 2015 01:43
hi, I'm using jQuery to post to an api ... I get back a value but only see it as [object Object] how do I see what's in there?
this is for the quote zipline
coop512c
@coop512c
Sep 09 2015 01:44
Where do I need double quotes? It didn't show double quotes in the example @chocobowings
Chocobowings
@chocobowings
Sep 09 2015 01:46
@coop512c Create an if-else statement here to return "heads" if flip is 0. Otherwise return "tails".
burySpot
@burySpot
Sep 09 2015 01:46
@coop512c you have to return "heads" or "tails", like strings, if you don't put the quotes, is like you're returning 2 vairables, one named head,s other named tails
coop512c
@coop512c
Sep 09 2015 01:46
I see, thank you @chocobowings and @burySpot
CamperBot
@camperbot
Sep 09 2015 01:46
coop512c sends brownie points to @chocobowings and @buryspot :sparkles: :thumbsup: :sparkles:
:star: 269 | @chocobowings | http://www.freecodecamp.com/chocobowings
:star: 163 | @buryspot | http://www.freecodecamp.com/buryspot
Chocobowings
@chocobowings
Sep 09 2015 01:47
@rgottleber did you try console.log the returned value ?
@rgottleber If you can show me your code I may be able to help you
Pedro Hernández
@PedroJS
Sep 09 2015 01:48

Noob here,
In this Waypoint: Give your JavaScript Slot Machine some stylish images

var images = ["http://i.imgur.com/9H17QFk.png", "http://i.imgur.com/9RmpXTy.png", "http://i.imgur.com/VJnmtt5.png"];

    slotOne = Math.floor(Math.random() * (3 - 1 + 1)) + 1;
    slotTwo = Math.floor(Math.random() * (3 - 1 + 1)) + 1;
    slotThree = Math.floor(Math.random() * (3 - 1 + 1)) + 1; 

$($('.slot')[0]).html('<img src = "' + images[slotOne-1] + '">');

why [slotOne-1], i don't get it, someone help please?

Richard Gottleber
@rgottleber
Sep 09 2015 01:50
@chocobowings thanks! should have thought of the console.. derp. I think I can maybe get there from here :)
CamperBot
@camperbot
Sep 09 2015 01:50
rgottleber sends brownie points to @chocobowings :sparkles: :thumbsup: :sparkles:
Mateja Trifunovski
@Matko95
Sep 09 2015 01:50
@PedroJS You are making random numbers from 1-3 , so they are 1,2,3 , and you need to access elements at 0,1,2 positions
CamperBot
@camperbot
Sep 09 2015 01:50
:star: 270 | @chocobowings | http://www.freecodecamp.com/chocobowings
ryana11
@ryana11
Sep 09 2015 01:50
Math.floor(math.random() * (3 - 1 + 1)) + 1; How do i link this to my variables http://freecodecamp.com/challenges/waypoint-create-a-javascript-slot-machine
Graham Whitley
@lotusgraham
Sep 09 2015 01:52
Screen Shot 2015-09-08 at 9.52.13 PM.png
Hey I'm new to bonfires and having trouble reversing a string. can someone give me some good advice about dealing with this one?
Chocobowings
@chocobowings
Sep 09 2015 01:53
@lotusgraham You can think of strings as arrays for example. That's one approach.
This message was deleted
Mateja Trifunovski
@Matko95
Sep 09 2015 01:54
@lotusgraham You see those helpful links at the left side? spend some time reading about them and try to combine all three of them
Daniel Drasdo
@danieldrasdo
Sep 09 2015 01:55
Salutations fellow FCCers, anyone here no a thing or two about 'orbital periods'? My math skills aren't the greatest.
Graham Whitley
@lotusgraham
Sep 09 2015 01:55
I have been trying that and it seems like a big leap from the way i have been processing info so far (super noob)
@chocobowings thanks @Matko95
CamperBot
@camperbot
Sep 09 2015 01:55
lotusgraham sends brownie points to @chocobowings and @matko95 :sparkles: :thumbsup: :sparkles:
:star: 271 | @chocobowings | http://www.freecodecamp.com/chocobowings
:star: 224 | @matko95 | http://www.freecodecamp.com/matko95
Chocobowings
@chocobowings
Sep 09 2015 01:55
@lotusgraham
var string = "hello";
string[0] = "h";
string[1]="e";
string[2]="l";
and so on;
Mateja Trifunovski
@Matko95
Sep 09 2015 01:55
@lotusgraham Want me to explain a bit then?
Graham Whitley
@lotusgraham
Sep 09 2015 01:55
explanation i would love
DTing
@dting
Sep 09 2015 01:56
@lotusgraham
bf reverse
CamperBot
@camperbot
Sep 09 2015 01:56

:fire:Bonfire: Reverse a String :link:

function reverseString(str) {
  return str;
}

reverseString('hello');

Reverse the provided string.

more info:  bf details | bf links | hint

DTing
@dting
Sep 09 2015 01:56
bf links
Mateja Trifunovski
@Matko95
Sep 09 2015 01:57
@lotusgraham So we have a string, and we can use the str.split("") method and split the string into an array containing elements ['h','e','l','l','o'] etc. , which we can join later using the arr.join("") method
Hans van Riet
@hansinla
Sep 09 2015 01:57
@rgottleber you could use json.stringify or object the object in comsole and see how you can parse it. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
Mateja Trifunovski
@Matko95
Sep 09 2015 01:57
@lotusgraham all you have left is to use reverse method to reverse it in the meantime
Graham Whitley
@lotusgraham
Sep 09 2015 01:58
okay, that reinforces what i was reading, I will tinker some more and see what i can come up with @Matko95 thanks
CamperBot
@camperbot
Sep 09 2015 01:58
lotusgraham sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:warning: lotusgraham already gave matko95 points
Graham Whitley
@lotusgraham
Sep 09 2015 01:58
@dting thanks
John Nieves
@karn09
Sep 09 2015 01:59
hey all
quick question: are 'properties' and 'keys' different words for the same thing?
Daniel Drasdo
@danieldrasdo
Sep 09 2015 01:59
Anyone here want to help me out with my solution so far for 'Map the Debris'? I can see light at the end of the tunnel, but I think my function needs something.
Garrett Schultz
@garettschultz
Sep 09 2015 02:00
What does the number mean thats in brackets next to the button that directs to your account?
DTing
@dting
Sep 09 2015 02:00
@danieldrasdo what's your code look like?
Daniel Drasdo
@danieldrasdo
Sep 09 2015 02:00
function orbitalPeriod(arr) {
  var GM = 398600.4418;
  var earthRadius = 6367.4447;

  for(var i = 0; i < arr.length; i++) {
    console.log(arr[i]);
    arr[i].avgAlt = calc(arr[i].avgAlt);
    console.log(arr[i]);
  }

  function calc(x) {
    x += earthRadius;
    x = Math.pow(x,3);
    x /= GM;
    x = Math.pow(x,0.5);
    x = 2 * Math.PI * x;
    return Math.round(x);
  }

  return arr;
}

orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);
orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}]);
John Nieves
@karn09
Sep 09 2015 02:01
if I define:
```
var obj = { one:1, two:2, three:3, four:4, five:5 };
Object.keys(obj)
// ["one", "two", "three", "four", "five"]
Object.getOwnPropertyNames(obj)
// ["one", "two", "three", "four", "five"]
so, same thing?
Richard Gottleber
@rgottleber
Sep 09 2015 02:01
@chocobowings ok still struggling..
Daniel Drasdo
@danieldrasdo
Sep 09 2015 02:01
Just need some help with the calc() I think.
Richard Gottleber
@rgottleber
Sep 09 2015 02:01
http://forismatic.com/en/api/ this is a link to the api it looks like I'm not formatting my post correctly..
DTing
@dting
Sep 09 2015 02:02
bf map
CamperBot
@camperbot
Sep 09 2015 02:02

:fire:Bonfire: Map the Debris :link:

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

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

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

more info:  bf details | bf links | hint

Daniel Drasdo
@danieldrasdo
Sep 09 2015 02:02
nf links
bf links
CamperBot
@camperbot
Sep 09 2015 02:02
links:
Daniel Drasdo
@danieldrasdo
Sep 09 2015 02:02
bf details
CamperBot
@camperbot
Sep 09 2015 02:02

:fire:Bonfire: Map the Debris :link:

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

orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);
Return a new array that transforms the element's average altitude into their orbital periods.
The array will contain objects in the format <code>{name: 'name', avgAlt: avgAlt}</code>.
You can read about orbital periods <a href="http://en.wikipedia.org/wiki/Orbital_period" target='_blank'>on wikipedia</a>.
The values should be rounded to the nearest whole number. The body being orbited is Earth.
The radius of the earth is 6367.4447 kilometers, and the GM value of earth is 398600.4418
Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>RSAP</a> if you get stuck. Try to pair program. Write your own code.
links:
Garrett Schultz
@garettschultz
Sep 09 2015 02:02
Im new to FCC. What does the number mean thats in brackets next to the button that directs to your account?
Daniel Drasdo
@danieldrasdo
Sep 09 2015 02:03
semi-major axis would be the earth's radius plus the avg Alt right?
Garrett Schultz
@garettschultz
Sep 09 2015 02:03
Capture.PNG
John Nieves
@karn09
Sep 09 2015 02:04
@gratschultz2013 that's the amount of points you've received, basically how much you've completed
Garrett Schultz
@garettschultz
Sep 09 2015 02:04
okay thank you
CamperBot
@camperbot
Sep 09 2015 02:04
if you want to thank someone, put an @ before their name!
John Nieves
@karn09
Sep 09 2015 02:04
np
Garrett Schultz
@garettschultz
Sep 09 2015 02:04
thank you @karn09
CamperBot
@camperbot
Sep 09 2015 02:04
gratschultz2013 sends brownie points to @karn09 :sparkles: :thumbsup: :sparkles:
:star: 152 | @karn09 | http://www.freecodecamp.com/karn09
DTing
@dting
Sep 09 2015 02:06
@danieldrasdo your code is correct except,
{name: "sputnik", orbitalPeriod: 86400}
thats the expected result
yours is
{"name":"sputnik","avgAlt":86400}
err oops
Daniel Drasdo
@danieldrasdo
Sep 09 2015 02:06
yea I get it, mines alt or whatever, okay cool!
big thanks to you @dting !
CamperBot
@camperbot
Sep 09 2015 02:07
danieldrasdo sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1064 | @dting | http://www.freecodecamp.com/dting
DTing
@dting
Sep 09 2015 02:07
np
Daniel Drasdo
@danieldrasdo
Sep 09 2015 02:10
that did it, thanks again @dting
CamperBot
@camperbot
Sep 09 2015 02:10
danieldrasdo sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:warning: danieldrasdo already gave dting points
Daniel Drasdo
@danieldrasdo
Sep 09 2015 02:13
Man, that bf's description could use some love, I didn't see the thing about a property needing to be orbitalPeriod anywhere.
DTing
@dting
Sep 09 2015 02:14
haha ya
had to look at the tests
maybe file an issue @danieldrasdo
Daniel Drasdo
@danieldrasdo
Sep 09 2015 02:15
Yea I might, because the tests for me just state "deeply equal [ Array(1) ]"
good idea.
DTing
@dting
Sep 09 2015 02:15
ya you have to look at
.to.eqls([{name: "sputnik", orbitalPeriod: 86400}]);
Mateja Trifunovski
@Matko95
Sep 09 2015 02:15
http://codepen.io/Matko95/pen/XmJvrL
Anyone knows why my icons won't show? The code is at the bottom of the jquery
Daniel Drasdo
@danieldrasdo
Sep 09 2015 02:15
oh I see it now!
"I am not a smart man." ~Forrest Gump.
DTing
@dting
Sep 09 2015 02:17
@Matko95 it works for me
Mateja Trifunovski
@Matko95
Sep 09 2015 02:18
you see the icons?
not the pictures on the left
DTing
@dting
Sep 09 2015 02:18
oh
Screen Shot 2015-09-08 at 7.18.05 PM.png
i see
no let me look again
Mateja Trifunovski
@Matko95
Sep 09 2015 02:18
<i class="+obj.icon+"></i></div></div> this part
DTing
@dting
Sep 09 2015 02:19
<i class="green" fa="" fa-circle=""></i>
thats what your actual css looks like
err html looks like
Mateja Trifunovski
@Matko95
Sep 09 2015 02:22
hmm how come
DTing
@dting
Sep 09 2015 02:24
You forgot to include a " in your string
        $("#twitch").append('<div class="media"><span class="media-left"><img style="pull-left" src="' + obj.logo + '" class="logo"></span><div class="media-body"><h1>' + obj.name + '</h1><i class="' + obj.icon + '"></i></div>');
Mateja Trifunovski
@Matko95
Sep 09 2015 02:25
@dting True, i get lost in all those apostrophe
DTing
@dting
Sep 09 2015 02:26
ya
Graham Whitley
@lotusgraham
Sep 09 2015 02:27
i've done all the challenges up to this point but dont feel like i'm retaining enough to be able to figure this out.
Screen Shot 2015-09-08 at 10.26.22 PM.png
Mateja Trifunovski
@Matko95
Sep 09 2015 02:28
@dting Thanks :)
CamperBot
@camperbot
Sep 09 2015 02:28
matko95 sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1065 | @dting | http://www.freecodecamp.com/dting
Matt Everson
@matteverson
Sep 09 2015 02:30
@lotusgraham Look at the functions in the "Helpful Links" section. This is a point where RSAP becomes more critical. The bonfires are pushing you to learn about javascript functions that haven't been covered yet.
CamperBot
@camperbot
Sep 09 2015 02:30
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Mateja Trifunovski
@Matko95
Sep 09 2015 02:31
@lotusgraham mega hint for you :D
str="lotus";
arr=str.split("");
//arr becomes [l,o,t,u,s]
arr.reverse();
//arr becomes [s,u,t,o,l]
DTing
@dting
Sep 09 2015 02:35
@lotusgraham your code needs to go inside the function
not after it
Pedro Hernández
@PedroJS
Sep 09 2015 02:36
@Matko95 @lotusgraham I'm stuck in the same waypoint
function reverseString(str) {
  myArray = str.split("");

  return str;
}

reverseString('hello');
Mateja Trifunovski
@Matko95
Sep 09 2015 02:37
@PedroJS you started nicely, what is the issue?
Pedro Hernández
@PedroJS
Sep 09 2015 02:38
It doesn't split @Matko95, it keep being hello or that's what the console says
Mateja Trifunovski
@Matko95
Sep 09 2015 02:39
because your function returns str
Pedro Hernández
@PedroJS
Sep 09 2015 02:39
ohhh @Matko95
Mateja Trifunovski
@Matko95
Sep 09 2015 02:39
try returning myArray[0];
ryana11
@ryana11
Sep 09 2015 02:40
[img]http://i.imgur.com/GdCmOki.png?1[/img] How do I link my Math.floor statements to my variables?
Moisés Man
@moigithub
Sep 09 2015 02:42
Math.floor is a function
and it returns something
variable = Math.floor( etc ....
Ben Hart
@Benjmhart
Sep 09 2015 02:42
has anyone gotten the quote-gen API working?
Mateja Trifunovski
@Matko95
Sep 09 2015 02:42
@ryana11 slotOne=math.Floor(math.Random()*3-1+1))+1;
@Benjmhart nope :D I've seen 1 guy doing it though
Matt Everson
@matteverson
Sep 09 2015 02:42
@Benjmhart I have
Ben Hart
@Benjmhart
Sep 09 2015 02:43
@matteverson how do you do the call?
Matt Everson
@matteverson
Sep 09 2015 02:43
What do you have so far?
ryana11
@ryana11
Sep 09 2015 02:43
@Matko95 Thank you! That took a lot longer then it should have
CamperBot
@camperbot
Sep 09 2015 02:43
ryana11 sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:star: 225 | @matko95 | http://www.freecodecamp.com/matko95
Ben Hart
@Benjmhart
Sep 09 2015 02:44
@matteverson did you use forismatic or some other API?
function quote2 on there
Mateja Trifunovski
@Matko95
Sep 09 2015 02:45
@Benjmhart A dead dude :D
Matt Everson
@matteverson
Sep 09 2015 02:45
@Benjmhart I used quotes on design, they all work roughly the same
Ben Hart
@Benjmhart
Sep 09 2015 02:46
I'm going to use quotes on design - you're the second person who used them succesfully and the implementation is straightforward.
Matt Everson
@matteverson
Sep 09 2015 02:46
@Benjmhart You'll want to make use of http://api.jquery.com/jquery.getjson/
Pedro Hernández
@PedroJS
Sep 09 2015 02:46
@Matko95 figured it out, thanks :clap:
CamperBot
@camperbot
Sep 09 2015 02:46
pedrojs sends brownie points to @matko95 :sparkles: :thumbsup: :sparkles:
:star: 226 | @matko95 | http://www.freecodecamp.com/matko95
Mateja Trifunovski
@Matko95
Sep 09 2015 02:46
@PedroJS glad you did :D
Ben Hart
@Benjmhart
Sep 09 2015 02:46
thanks @matteverson
CamperBot
@camperbot
Sep 09 2015 02:46
benjmhart sends brownie points to @matteverson :sparkles: :thumbsup: :sparkles:
:star: 377 | @matteverson | http://www.freecodecamp.com/matteverson
Graham Whitley
@lotusgraham
Sep 09 2015 02:50
@matteverson @Matko95 @dting Thank you @PedroJS
CamperBot
@camperbot
Sep 09 2015 02:50
lotusgraham sends brownie points to @matteverson and @matko95 and @dting and @pedrojs :sparkles: :thumbsup: :sparkles:
:warning: lotusgraham already gave matko95 points
:star: 159 | @pedrojs | http://www.freecodecamp.com/pedrojs
:star: 378 | @matteverson | http://www.freecodecamp.com/matteverson
:star: 1066 | @dting | http://www.freecodecamp.com/dting
Austin Lin
@austinylin
Sep 09 2015 02:50
Hi everyone
Steven Nevins
@dmintercept
Sep 09 2015 02:50
so many brownie points
Hans van Riet
@hansinla
Sep 09 2015 02:55
@danieldrasdo You should declare a new array and push the results from your calc function into that new array. Your orbitalPeriod function should return the newly created array.
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 02:57
bonfire where art thou
CamperBot
@camperbot
Sep 09 2015 02:57

:fire:Bonfire: Where art thou :link:

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

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

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

more info:  bf details | bf links | hint

Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 02:57
i have no idea where to start with this one
can i get an assist?
Austin Lin
@austinylin
Sep 09 2015 02:59
bf links
DTing
@dting
Sep 09 2015 02:59
return the result of filtering the array. the filter call back function should return whether or not the item the callback function is called with has ALL the properties of the source object and that all the values for the properties are equal
Austin Lin
@austinylin
Sep 09 2015 02:59
@psykobilliethekid I would suggest starting with checking if the objects in collection have all of the keys in source. You can use hasOwnProperty() to query.
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 03:00
@dting @austinylin ok. ill try both and see what happens. thanks guys
CamperBot
@camperbot
Sep 09 2015 03:00
psykobilliethekid sends brownie points to @dting and @austinylin :sparkles: :thumbsup: :sparkles:
:star: 59 | @austinylin | http://www.freecodecamp.com/austinylin
:star: 1067 | @dting | http://www.freecodecamp.com/dting
3The3Kodiak3
@3The3Kodiak3
Sep 09 2015 03:01
Hey, could anyone possible help me out with Waypoint: Manipulate Arrays With unshift. The instructions are kind of confusing to me

'''js
var ourArray = ["Stimpson", "J", ["cat"]];
ourArray.shift();
ourArray.unshift(["happy", "joy"]);
// ourArray now equals [["happy", "joy"], "J", ["cat"]]

var myArray = ["John", 23, ["dog", 3]];
myArray.shift();

// Add "Paul" to the start of myArray
// Only change code below this line.

// Only change code above this line.
// We use this function to show you the value of your variable in your output box.
// You'll learn about functions soon.
(function(y, z){return 'myArray = ' + JSON.stringify(y);})(myArray);
'''

CamperBot
@camperbot
Sep 09 2015 03:03
:bulb: to format code use backticks! ``` more info
Austin Lin
@austinylin
Sep 09 2015 03:03
bf multiple arrays
CamperBot
@camperbot
Sep 09 2015 03:03
Sorry, can't find a bonfire called multiple arrays. [ Check the map? ]
3The3Kodiak3
@3The3Kodiak3
Sep 09 2015 03:03
```var ourArray = ["Stimpson", "J", ["cat"]];
ourArray.shift();
ourArray.unshift(["happy", "joy"]);
// ourArray now equals [["happy", "joy"], "J", ["cat"]]
var myArray = ["John", 23, ["dog", 3]];
myArray.shift();
// Add "Paul" to the start of myArray
// Only change code below this line.
// Only change code above this line.
// We use this function to show you the value of your variable in your output box.
// You'll learn about functions soon.
(function(y, z){return 'myArray = ' + JSON.stringify(y);})(myArray);
Austin Lin
@austinylin
Sep 09 2015 03:03
wp multiple arrays with unshift
DTing
@dting
Sep 09 2015 03:04
@3The3Kodiak3
// Add "Paul" to the start of myArray
// Only change code below this line.
// Only change code above this line.
find unshift
CamperBot
@camperbot
Sep 09 2015 03:04
look at the "examples"
theres not much help we can give on that one with out just giving you the answer
Muhammad Mamun Hossain
@mamun2015
Sep 09 2015 03:08

''' // Only change code below this line.

myArray.unshift("paul");

CamperBot
@camperbot
Sep 09 2015 03:08
:bulb: to format code use backticks! ``` more info
Muhammad Mamun Hossain
@mamun2015
Sep 09 2015 03:08
'''
CamperBot
@camperbot
Sep 09 2015 03:08
:bulb: to format code use backticks! ``` more info
3The3Kodiak3
@3The3Kodiak3
Sep 09 2015 03:09
Got it. I was adding brackets [ ] inside the parentheses, but I didn't need to. Thank you @austinylin
thank you @dting Thank you @mamun2015
CamperBot
@camperbot
Sep 09 2015 03:09
3the3kodiak3 sends brownie points to @austinylin and @dting and @mamun2015 :sparkles: :thumbsup: :sparkles:
:star: 341 | @mamun2015 | http://www.freecodecamp.com/mamun2015
:star: 62 | @austinylin | http://www.freecodecamp.com/austinylin
:star: 1069 | @dting | http://www.freecodecamp.com/dting
Harry Gill
@mygnu
Sep 09 2015 03:12
Bot test thanks @mygnu
CamperBot
@camperbot
Sep 09 2015 03:12
no wiki entry for: test thanks @mygnu
:pencil: click here to create one now!after creating your page type update to reload it here
Harry Gill
@mygnu
Sep 09 2015 03:12
Lol
Aleksandr Sidorov
@AleksandrSidorov
Sep 09 2015 03:20
Hello, everybody!
Austin Lin
@austinylin
Sep 09 2015 03:20
Hi
Matt Everson
@matteverson
Sep 09 2015 03:20
Hello
Rex Schrader
@SaintPeter
Sep 09 2015 03:21
Hello! Is this the hello test channel?
SaintPeter @SaintPeter tests his "Hello"
Aleksandr Sidorov
@AleksandrSidorov
Sep 09 2015 03:24
I'm trying to manage twitter button for Quote Machine zipline. Twitter Button (https://dev.twitter.com/web/tweet-button) is real pain.
Rex Schrader
@SaintPeter
Sep 09 2015 03:25
@shtil80 Look for Twitter Intent Tweet. There is a simple URL to do it. Bring your own button.
Aleksandr Sidorov
@AleksandrSidorov
Sep 09 2015 03:26
@SaintPeter That is exactli what I'm trying to use.
Rex Schrader
@SaintPeter
Sep 09 2015 03:26
@shtil80 Ok, then what is the trouble? Do you know how to change the href of an existing link using jQuery?
Aleksandr Sidorov
@AleksandrSidorov
Sep 09 2015 03:27
@SaintPeter I'm using pure JS and I know how to change href, but twitter API doing such a mess in my code...
@SaintPeter just a moment, I'll show my code...
Rex Schrader
@SaintPeter
Sep 09 2015 03:29
@shtil80 Well, don't use twitter's magical button making code - it creates an iframe that cannot be updated once created. Not sure why anyone would willingly use pure JS, but more power to you. You should be able to update the href attribute of an arbitrary link using pure JS.
Aleksandr Sidorov
@AleksandrSidorov
Sep 09 2015 03:32
@SaintPeter http://codepen.io/shtil80/full/VvLYyW I'm out of ideas how to change the 'href' right.
Harry Gill
@mygnu
Sep 09 2015 03:32
@stil80 you can simply try to set an attribute url to the button with the message, tip: see the freecodecamp implementation of the challenge tweet button
Rex Schrader
@SaintPeter
Sep 09 2015 03:33
@shtil80 See above - if you use the magical button making code from twitter it creates it in an iframe and the URL cannot be updated after creation.
Harry Gill
@mygnu
Sep 09 2015 03:35
My approach is to use the available tools to make your life easier :)
Aleksandr Sidorov
@AleksandrSidorov
Sep 09 2015 03:36
@mygnu thanks. will examine fcc implementation.
@SaintPeter @mygnu so I shuoldn't use the Twitter button?
CamperBot
@camperbot
Sep 09 2015 03:36
shtil80 sends brownie points to @mygnu and @saintpeter and @mygnu :sparkles: :thumbsup: :sparkles:
:star: 552 | @saintpeter | http://www.freecodecamp.com/saintpeter
:star: 248 | @mygnu | http://www.freecodecamp.com/mygnu
:star: 248 | @mygnu | http://www.freecodecamp.com/mygnu
Rex Schrader
@SaintPeter
Sep 09 2015 03:36
My approach is to use the easiest tools to make your life easier because, seriously, who has time to reinvent the wheel everytime you make a website?

@shtil80

if you use the magical button making code from twitter it creates it in an iframe and the URL cannot be updated after creation.

Don't know how many more times I gotta say it
Aleksandr Sidorov
@AleksandrSidorov
Sep 09 2015 03:38
@SaintPeter I got it. And what is the easiest tool fot this case? I'm just lack of experience in this field.
Rex Schrader
@SaintPeter
Sep 09 2015 03:38
@shtil80 jQuery - makes it really easy to select HTML elements and change their attributes.
woodnti
@woodnti
Sep 09 2015 03:39
This message was deleted
Rex Schrader
@SaintPeter
Sep 09 2015 03:39
@shtil80 As for generating the URL, see here: https://dev.twitter.com/web/tweet-button/web-intent - you can generate a raw URL, no special code needed. Just add that URL to the href of your link.
Aleksandr Sidorov
@AleksandrSidorov
Sep 09 2015 03:41
@SaintPeter But with Magic Twitter Button it is doesn't matter. if you use the magical button making code from twitter it creates it in an iframe and the URL cannot be updated after creation.
Rex Schrader
@SaintPeter
Sep 09 2015 03:42
@shtil80 You can generate one button, sure. But when you click your "get a quote" link, you're not going to be able to update the Magic Twitter button. Did you follow the link about Tweet Web Intent? It shows you how to make a URL (IE: a plain old link) that will post an arbitrary tweet.
Harry Gill
@mygnu
Sep 09 2015 03:47
'''$("#tweet").attr("href", "https://twitter.com/intent/tweet?text=" + encodeURI(current_quote));'''
CamperBot
@camperbot
Sep 09 2015 03:47
:bulb: to format code use backticks! ``` more info
Harry Gill
@mygnu
Sep 09 2015 03:47
$("#tweet").attr("href", "https://twitter.com/intent/tweet?text=" + encodeURI(current_quote));
something like this @shtil80
Aleksandr Sidorov
@AleksandrSidorov
Sep 09 2015 03:48
@SaintPeter Something becomes clearer... 1. I don't need twitter API at all. 2. My tweet button ust redirect to 'twitter.com/intent/tweet'; with ?text=... which I can change.
Rex Schrader
@SaintPeter
Sep 09 2015 03:49
@shtil80 Precisely. You'll probably also want to set target="_blank" for your URL, because otherwise Codepen give you trouble - anyway, openining in another window is for the best.
Aleksandr Sidorov
@AleksandrSidorov
Sep 09 2015 03:51
@mygnu @SaintPeter Thank you very much! Sadly, I stick to this 'Twiteer API' thing and couldn't move further.
CamperBot
@camperbot
Sep 09 2015 03:51
shtil80 sends brownie points to @mygnu and @saintpeter :sparkles: :thumbsup: :sparkles:
:warning: shtil80 already gave saintpeter points
:warning: shtil80 already gave mygnu points
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 03:56
bonfire seek and destroy
CamperBot
@camperbot
Sep 09 2015 03:56

:fire:Bonfire: Seek and Destroy :link:

function destroyer(arr) {
  // Remove all the values
  return arr;
}

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

You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.

more info:  bf details | bf links | hint

Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 03:56
im guessing i need to iterate through the array and compare the args
Austin Lin
@austinylin
Sep 09 2015 03:56
@psykobilliethekid or use Array.filter
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 03:56
can you explain to me how array.filter works?
i think i understand but im still a little lost
Austin Lin
@austinylin
Sep 09 2015 03:57
@psykobilliethekid you also need to use the arguments special array to get ahold of the actually args, notice that there are more args than the function calls for
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 03:58
@austinylin so use array.prototype.args? im really confused on this one. sorry! :-/
Harry Gill
@mygnu
Sep 09 2015 03:58
@psykobilliethekid compare and filter store in a new array and return that
Austin Lin
@austinylin
Sep 09 2015 03:59
Array.filter returns a new array with all elements that return true for the callback. basically:
newArr = oldArr.filter(function (e) { 
// if you return true here e will be in newArr, otherewise it won’t
}):
bf links
CamperBot
@camperbot
Sep 09 2015 03:59
Austin Lin
@austinylin
Sep 09 2015 03:59
look at the first link
or actually both :)
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:00
sure. i think its a combination of being sick and the allergy meds cause i cant seem to get this one down for anything tonight
@austinylin thanks though. i appreciate the help
CamperBot
@camperbot
Sep 09 2015 04:00
psykobilliethekid sends brownie points to @austinylin :sparkles: :thumbsup: :sparkles:
:warning: psykobilliethekid already gave austinylin points
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:02
nope im still not getting it
wow this is pretty bad tonight
Austin Lin
@austinylin
Sep 09 2015 04:02
Did the arguments object make sense?
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:03
not really but ill keep reading it. hopefully something will click
so i need to change the arguments into an array? so something like arguments = new Array();
Danny Fritz
@dannyfritz
Sep 09 2015 04:06
changing arguments into an array is actually a complex statement
Harry Gill
@mygnu
Sep 09 2015 04:06
@psykobilliethekid
callback function rem(value){
      if(value is not in the array){
        return;
      } else { return value;}
}
Danny Fritz
@dannyfritz
Sep 09 2015 04:06
but it would be something like
var args = Array.prototype.slice.call(arguments);
Aleksandr Sidorov
@AleksandrSidorov
Sep 09 2015 04:09
oh, wait... twitter bootstrap don't have a twitter glyphicon.
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:10
so would this be along the right track?
var args = Array.prototype.slice.call(arguments);
for (i = 0; 0 <= args.length; i++){
   if (args.indexOf[i] === array.indexOf[i]{
      array.remove[i];
    }
}
more or less what i will try out
Matthew Thompson
@pyrochemist
Sep 09 2015 04:11
@shtil80 FontAwesome has it
Aleksandr Sidorov
@AleksandrSidorov
Sep 09 2015 04:11
@pyrochemist thanks!
CamperBot
@camperbot
Sep 09 2015 04:11
shtil80 sends brownie points to @pyrochemist :sparkles: :thumbsup: :sparkles:
:star: 181 | @pyrochemist | http://www.freecodecamp.com/pyrochemist
DavidThms
@DavidThms
Sep 09 2015 04:11

I can write the code but I don't understand how it works

return Math.floor(Math.random() * (max - min + 1)) + min;

can someone explain, is it even important that i understand it?

Matthew Thompson
@pyrochemist
Sep 09 2015 04:11
iirc it's fa-twitter
so you'd have to do class="fa fa-twitter" in whatever tag you want it on
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:12
@dannyfritz lets try this...
var args = Array.prototype.slice.call(arguments);
for (i = 0; i <= args.length; i++){
   if (args.indexOf[i] === array.indexOf[i]){
      array.remove[i];
   }
  }
}
@dannyfritz oh for the love of god...
var args = Array.prototype.slice.call(arguments);
for (i = 0; i <= args.length; i++){
   if (args.indexOf[i] === array.indexOf[i]){
      array.remove[i];
   }
  }
}
well yeah for the most part...
Aleksandr Sidorov
@AleksandrSidorov
Sep 09 2015 04:16
@pyrochemist works perfect!
Matthew Thompson
@pyrochemist
Sep 09 2015 04:17
@psykobilliethekid you can clean it up a little by doing
for (i = 0; i <= arguments.length; i++){
if (arguments[i] === array[i]) {
...
no need for the array.prototype.slice.call
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:17
@pyrochemist oh cool! thanks dude!
CamperBot
@camperbot
Sep 09 2015 04:17
psykobilliethekid sends brownie points to @pyrochemist :sparkles: :thumbsup: :sparkles:
:star: 182 | @pyrochemist | http://www.freecodecamp.com/pyrochemist
Matthew Thompson
@pyrochemist
Sep 09 2015 04:18
S&D is what my brother is on right now too.
I did it a bit hacky.
using filter
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:19
@pyrochemist i was trying to use filter and just got more confused
Matthew Thompson
@pyrochemist
Sep 09 2015 04:19
function destroyer(arr) {
  // Remove all the values
 //console.log(arguments);
  //console.log(arr);
  var filtered = arr;

  for (i = 1; i < arguments.length; i++)
    {
      var itemtofilter = arguments[i];
      //console.log(itemtofilter);
      arr = arr.filter(
        function (value)
        {               

          if (value != itemtofilter)
            {
              console.log('notequal');
              return true;
            } else {
              console.log('equal');
              return false;
            }                     
        }
      );
    }    
  return arr;
}
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:19
like i mentioned before its either the my being sick, my allergy meds, or a combination of both that is making this hard tonight
Matthew Thompson
@pyrochemist
Sep 09 2015 04:19
mind my excessive console.log
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:20
oh yeah. console.log and i are best friends
@pyrochemist quick question, if you want to remove an element, you use .splice() right?
Matthew Thompson
@pyrochemist
Sep 09 2015 04:21
filter does it
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:22
ok. i think i understand that
so would this make sense then?
function destroyer(arr) {
  // Remove all the values
  //var args = Array.prototype.slice.call(arguments);

  for (i = 0; i <= arguments.length; i++){
    if (arguments[i] === array[i]) {{
      arr.filter[i];
    }
   }
}
i dont think it does but i have the feeling im on the right track
Matthew Thompson
@pyrochemist
Sep 09 2015 04:23
filter is a function, not an array so the []'s won't do anything. Filter calls a function to ask if a value should be filtered out or not.
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:24
oh! thats right! so would it be arr.filter(i)
Matthew Thompson
@pyrochemist
Sep 09 2015 04:24
ok, so question for you, what is i?
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:25
what im comparing
so wait...would it be arguments.filter(i)?
no it wouldnt be...
argh....this sucks...
Matthew Thompson
@pyrochemist
Sep 09 2015 04:26
So i in this case is going to be changing each time it loops through, from 0 to the length of the # of arguments
so you'd be filtering 0, 1,2,3,4,5
What you want to do is filter the value of the argument from the array
The way filter works is a bit different than other functions as it uses what is called a callback in one of its values you pass to it.
Andrew Uckotter
@uckotter
Sep 09 2015 04:28
Thanks @Rafase282 @kirah1314n
CamperBot
@camperbot
Sep 09 2015 04:28
kmhau82 sends brownie points to @rafase282 and @kirah1314n :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for kirah1314n
:star: 418 | @rafase282 | http://www.freecodecamp.com/rafase282
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:28
so to filter the value of the argument from the array, would i do argument.value.filter()
Matthew Thompson
@pyrochemist
Sep 09 2015 04:28
So you would want to filter arr by doing arr.filter(value)
Harry Gill
@mygnu
Sep 09 2015 04:28
@psykobilliethekid you need to extract the first array from the arguments using
Array.prototype.slice.call(arguments,1);
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:28
@pyrochemist dang! i was close!
Matthew Thompson
@pyrochemist
Sep 09 2015 04:28
very
So one way of doing it is by putting a function there to evaluate if the item to filter should be filtered out

'''
arr = arr.filter(
function (value)
{

      if (value != itemtofilter)
        {
          console.log('notequal');
          return true;
        } else {
          console.log('equal');
          return false;
        }                     
    }

'''

CamperBot
@camperbot
Sep 09 2015 04:29
:bulb: to format code use backticks! ``` more info
Matthew Thompson
@pyrochemist
Sep 09 2015 04:29
weird.. uhm
      arr = arr.filter(
        function (value)
        {               

          if (value != itemtofilter)
            {
              console.log('notequal');
              return true;
            } else {
              console.log('equal');
              return false;
            }                     
        }
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:30
oh! oh i get it now! it finally clicked! mind if i use your layout to try this out?
Matthew Thompson
@pyrochemist
Sep 09 2015 04:30
Sure
just don't forget to assign the variable itemtofilter to be the arguments[i]
```
var itemtofilter = arguments[i];
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:31
@pyrochemist thank you! yes i think i get this now!
CamperBot
@camperbot
Sep 09 2015 04:31
psykobilliethekid sends brownie points to @pyrochemist :sparkles: :thumbsup: :sparkles:
:warning: psykobilliethekid already gave pyrochemist points
Matthew Thompson
@pyrochemist
Sep 09 2015 04:32
Where Art Thou and this one were the challenging ones
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:36
yes. yes they are!
would you believe its still saying undefined?
function destroyer(arr) {
  // Remove all the values

  for (i = 0; i <= arguments.length; i++){
    if (arguments[i] === arr[i]) {
      arr = arr.filter(
        function(value){
          var filtered = arguments[i];
          if (value != filtered){
            return true;
          }
          else{
            return false;
          }
        }
    );}
  }
}
Alejandro Tejada
@wannabecoding
Sep 09 2015 04:38
Hi all.
Any good resource on APIs? First time I run into this and I'm lost :)
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:38
@pyrochemist maybe you can see what i missed
Hans van Riet
@hansinla
Sep 09 2015 04:38
@wannabecoding hi!
Matthew Thompson
@pyrochemist
Sep 09 2015 04:38
@psykobilliethekid var filtered = arguments[i] needs to be above arr = arr.filter(
the arguments array is for the function it is within (the scope)
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:39
scope is killing me!
i keep thinking im ok but im always not
Matthew Thompson
@pyrochemist
Sep 09 2015 04:40
you also can remove the if (arguments[i] === arg[i] { and the corresponding close bracket
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:40
guess its a good way to learn, right?
Paul Simon Ongpin
@mochiii
Sep 09 2015 04:40
This message was deleted
CamperBot
@camperbot
Sep 09 2015 04:40
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Matthew Thompson
@pyrochemist
Sep 09 2015 04:40
yes, accept mistakes will happen & working-but-not-quite-right ways of doing things
I always run into a different (usually better) way of doing something because I didn't know about some random extension or API.
Alejandro Tejada
@wannabecoding
Sep 09 2015 04:42
Any documentation I can read on API's in general? I have no prior experience with them and don't have a clue how to call it
Matthew Thompson
@pyrochemist
Sep 09 2015 04:43
@wannabecoding API's for which service?
Alejandro Tejada
@wannabecoding
Sep 09 2015 04:43
I'm on the zipline for the Random Quote Generator
I see their API page, but I've never worked with an API before
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:44
@pyrochemist ok so here's what i have now
function destroyer(arr) {
  // Remove all the values 
  for (i = 0; i <= arguments.length; i++){
      var filtered = arguments[i];
      arr = arr.filter(
                function(value){
          if (value != filtered){
            return true;
          }
          else{
            return false;
          }
        }
      ); 
  }
}
i understand whats going on but i cant find the problem area
Matthew Thompson
@pyrochemist
Sep 09 2015 04:44
and return arr
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:44
omg i deleted the return
thank you for seeing that
CamperBot
@camperbot
Sep 09 2015 04:44
if you want to thank someone, put an @ before their name!
Matthew Thompson
@pyrochemist
Sep 09 2015 04:45
@wannabecoding are you using jquery?
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 04:45
and there it goes! finally! thank you @pyrochemist! i appreciate it!
CamperBot
@camperbot
Sep 09 2015 04:45
psykobilliethekid sends brownie points to @pyrochemist :sparkles: :thumbsup: :sparkles:
:warning: psykobilliethekid already gave pyrochemist points
Matthew Thompson
@pyrochemist
Sep 09 2015 04:45
@psykobilliethekid glad I could help
Alejandro Tejada
@wannabecoding
Sep 09 2015 04:46
@pyrochemist I can if it's necessary
The info on their API page doesn't really help me
Matthew Thompson
@pyrochemist
Sep 09 2015 04:48
@wannabecoding in jquery, using get you can fetch the API URL into a variable for you to get the data out of it
Alejandro Tejada
@wannabecoding
Sep 09 2015 04:49
I had no clue such a thing existed lol, thanks! I'm going to figure this out now
CamperBot
@camperbot
Sep 09 2015 04:49
if you want to thank someone, put an @ before their name!
Alejandro Tejada
@wannabecoding
Sep 09 2015 04:49
:+1:
Matthew Thompson
@pyrochemist
Sep 09 2015 04:50
You'll need it for the weather bonfire as well
zipline
Alejandro Tejada
@wannabecoding
Sep 09 2015 04:51
will keep that in mind, hopefully I will be on that zipline before long
Eva
@evasyl1
Sep 09 2015 04:57
Hi, I am stuck on the Bonfire Find the Longest Word. I split the string into an array. Then I tried to sort the array by length as discussed at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort and on other websites. I got myArray.sort(function(a, b){return a.length-b.length}); and it wasn
  • it wasn't doing anything. I finally set it to return myArray.sort(function(a, b){return a.length-b.length}); and it just returned the test sentence in its original order.
Bill
@kirah1314
Sep 09 2015 04:58
@evasyl1 what does your code look like now? Can you paste it in the code format?
help format
CamperBot
@camperbot
Sep 09 2015 04:58

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Eva
@evasyl1
Sep 09 2015 05:01
function findLongestWord(str) {
  var myArray = str.split();
  myArray.sort(function(a, b){return a.length-b.length});

}

findLongestWord('The quick brown fox jumped over the lazy dog');
DTing
@dting
Sep 09 2015 05:02
@evasyl1 you need to return something
also str.split() just returns the string inside an array
you need a separator
'hello'.split();
// ['hello']
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 05:06
@pyrochemist finally finished the first set of bonfires. thank you again for your help! i was really stuck on that one
Matthew Thompson
@pyrochemist
Sep 09 2015 05:08
The Ziplines are fun
Danielle "Dani" Moss
@psykobilliethekid
Sep 09 2015 05:09
they look like they are. looking forward to working on them
Eva
@evasyl1
Sep 09 2015 05:09
@dting oh, right, str.split(" "). I know I need to return something, but I don't know what to ask it to return.
Bill
@kirah1314
Sep 09 2015 05:10
@evasyl1 sort() method is going to sort by Unicode code, so you may want to use a different approach. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
@evasyl1 I used a for loop and if statement if you're looking for some hints
DTing
@dting
Sep 09 2015 05:12
@evasyl1 your approach is fine. sorting by the lengths the words will result in the array being sorted by length. the problem you might encounter is that .sort isnt stable on all browsers
i would suggest using console.log(myArray); after you sort. and see what the array looks like
you can probably figure out what to return from there
bf longest
CamperBot
@camperbot
Sep 09 2015 05:14

:fire:Bonfire: Find the Longest Word in a String :link:

function findLongestWord(str) {
  return str.length;
}

findLongestWord('The quick brown fox jumped over the lazy dog');

Return the length of the longest word in the provided sentence.

more info:  bf details | bf links | hint

Eva
@evasyl1
Sep 09 2015 05:15
@kirah1314 I have come across some for loop and if statement versions of this problems online, but I guess I am stuck on what I need to declare as the variables. http://davidbcalhoun.com/2013/you-cant-javascript-under-pressure-walkthrough/
DTing
@dting
Sep 09 2015 05:17
Screen Shot 2015-09-08 at 10.16.49 PM.png
if you return your array "myArray" you can see in the box on the left what that array looks like
which element do you want the length of?
Eva
@evasyl1
Sep 09 2015 05:18
@dting I want the length of the longest element
DTing
@dting
Sep 09 2015 05:18
which one is the longest?
Jonathan
@jcadle
Sep 09 2015 05:21
anyone else having trouble with the Bonfire: Mutations ?
Eva
@evasyl1
Sep 09 2015 05:21
@dting for the given test sentence "jumped" is longest. i'm supposed to get 6 as my result, for 6 letters in "jumped."
Bill
@kirah1314
Sep 09 2015 05:21
@evasyl1 I misread, yeah if you sort by length then it's just numbers. @dting is right
DTing
@dting
Sep 09 2015 05:21
so you want to return the length of the last element in your array
how do you get the last element in your array?
Eva
@evasyl1
Sep 09 2015 05:24
@dting return []; but I'm not sure what goes between the brackets

to access array items using bracket notation.

var arr = [0,1,2,3,4];
arr[0];
// 0
arr[1];
// 1
arr[2];
// 2
...

Notice the array's index starts at $0$.

to get the last element of the array you can use
var a = ["hi", "hello", "good", "bye"];
a[a.length-1];
// "bye"
Eva
@evasyl1
Sep 09 2015 05:29
function findLongestWord(str) {
  var myArray = str.split(" ");
  myArray.sort(function(a, b){return a.length-b.length});
  return [0];
}

findLongestWord('The quick brown fox jumped over the lazy dog');
for that code, it returns [0].
DTing
@dting
Sep 09 2015 05:29
that creats an array
function findLongestWord(str) {
  var myArray = str.split(' ');
  myArray.sort(function(a, b){return a.length-b.length});
  return myArray[myArray.length-1].length;
}
or to make it easier you could flip your sort function
function findLongestWord(str) {
  var myArray = str.split(' ');
  myArray.sort(function(a, b){return b.length-a.length}); // reversing a and b sorts array the other way
  return myArray[0].length;
}
i highly recommend you read though the mdn article on arrays i linked earlier.
Eva
@evasyl1
Sep 09 2015 05:32
@dting ok, it likes myArray[0].length. thanks!!
CamperBot
@camperbot
Sep 09 2015 05:32
evasyl1 sends brownie points to @dting :sparkles: :thumbsup: :sparkles:
:star: 1070 | @dting | http://www.freecodecamp.com/dting
Eva
@evasyl1
Sep 09 2015 05:32
thank you to @kirah1314 as well.
CamperBot
@camperbot
Sep 09 2015 05:32
evasyl1 sends brownie points to @kirah1314 :sparkles: :thumbsup: :sparkles:
:star: 228 | @kirah1314 | http://www.freecodecamp.com/kirah1314
Jonathan
@jcadle
Sep 09 2015 05:38
okay, I figured it out
unknowntheory
@unknowntheory
Sep 09 2015 06:05
hey can someone please explain what [i] is?
Harry Gill
@mygnu
Sep 09 2015 06:11
@unknowntheory [] is the index accesser of an Array it starts from 0 ie arr[0] will return first element of the array
aslamweb
@aslamweb
Sep 09 2015 06:44
assert((function(){//if(typeof(myName) !== "undefined" && typeof(myName) === "string" && myName.length > 0){return true;}else{return false;}//})(), 'myName should be a string that contains at least one character in it');myName should
I dont know how to solve this task
marzelin
@marzelin
Sep 09 2015 07:01
@aslamweb which challenge is it?
sinnersdoom
@sinnersdoom
Sep 09 2015 07:17

can someone help me find the bug in my code

<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;
}

.smaller-image {
width: 100px;
}

.thin-green-border {
border: 10px solid green;
}
</style>

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

<img class="smaller-image" class="thin-green-order" src="https://bit.ly/fcc-relaxing-cat">

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

marzelin
@marzelin
Sep 09 2015 07:19
@sinnersdoom <img class="smaller-image" class="thin-green-order" src="https://bit.ly/fcc-relaxing-cat"> you have two class attributes
@sinnersdoom what is more you have a typo in class name
sinnersdoom
@sinnersdoom
Sep 09 2015 07:21
but the question says that i need to add a class "thin-green border" to the image and cannot delete the existing class
thanks for typo
CamperBot
@camperbot
Sep 09 2015 07:21
if you want to thank someone, put an @ before their name!
sinnersdoom
@sinnersdoom
Sep 09 2015 07:21
@marzelin thanks
CamperBot
@camperbot
Sep 09 2015 07:21
sinnersdoom sends brownie points to @marzelin :sparkles: :thumbsup: :sparkles:
:star: 147 | @marzelin | http://www.freecodecamp.com/marzelin
marzelin
@marzelin
Sep 09 2015 07:22
@sinnersdoom to add another class just class="smaller-image thin-green-border"
Mbos95
@Mbos95
Sep 09 2015 07:23
Hey guys!
Can one of you tell me why this returns such an weird error ?
function bouncer(arr) {

  var Boolean2 = new Boolean(false);

  arr.filter(Boolean2)
  return arr;
}

bouncer([7, 'ate', '', false, 9]);
sinnersdoom
@sinnersdoom
Sep 09 2015 07:24
This message was deleted
marzelin
@marzelin
Sep 09 2015 07:25
@Mbos95 check how filter method works
@Mbos95 you need to provide function to it
Mbos95
@Mbos95
Sep 09 2015 07:26
But I am not sure how... Should I use an for loop and iterate through?
That might makes sense,right?
marzelin
@marzelin
Sep 09 2015 07:28
@Mbos95
arr.filter(function(value){retrun value;});
Mbos95
@Mbos95
Sep 09 2015 07:28
so I need to write a function in the function ?
Mbos95
@Mbos95
Sep 09 2015 07:29
yea, I've looked there. They use it in the same way as I tried
arr.filter(variable with filterish thing in it)
marzelin
@marzelin
Sep 09 2015 07:30
@Mbos95 not quite usual variable, reference to a function
@Mbos95 you provided filter with just boolean value, so filter was just like "I need a function, what i am supposed to do with this boolean value, ERROR"
RobotEyes
@Roboteyes
Sep 09 2015 07:31
I need help!!
marzelin
@marzelin
Sep 09 2015 07:32
@Roboteyes what's happening!
Mbos95
@Mbos95
Sep 09 2015 07:37
function bouncer(arr) {
  var endarray = [];
  var falsearray= [];
  for(i=0;i < arr.length; i++){
    var input = arr[i]

    if(input === false){
      falsearray.push(input);

    }else{
      endarray.push(input);

    }



  }
  return endarray;
}

bouncer([7, 'ate', '', false, 9]);
Oke, why doesn't this work xD it is supposed to work!
because it is either true or false,right?
It only takes the literal false out of it
marzelin
@marzelin
Sep 09 2015 07:39
@Mbos95 because of this line if(input === false)
Mbos95
@Mbos95
Sep 09 2015 07:39
Do I need to specify booleans false?
marzelin
@marzelin
Sep 09 2015 07:39
it's only true for if input = false;
@Mbos95 try if(input)
Mbos95
@Mbos95
Sep 09 2015 07:40
oh...
Why does that work ?
Oh because if you just do this it´ll just do it when input is true! Not any weird specified ways or manners it can go wrong
THank you! :)
CamperBot
@camperbot
Sep 09 2015 07:40
if you want to thank someone, put an @ before their name!
Mbos95
@Mbos95
Sep 09 2015 07:41
thanks @marzelin
CamperBot
@camperbot
Sep 09 2015 07:41
mbos95 sends brownie points to @marzelin :sparkles: :thumbsup: :sparkles:
:star: 148 | @marzelin | http://www.freecodecamp.com/marzelin
marzelin
@marzelin
Sep 09 2015 07:42
@Mbos95 JavaScript is a language with dynamic types. if expects expression inside parentheses to be boolean value. If it's not it converts whatever value is there to boolean value
RobotEyes
@Roboteyes
Sep 09 2015 07:42
I'm just starting and i'm on Waypoint: Uncomment HTML, How do i delete all trailing comment tags, i.e.? @marzelin
Mbos95
@Mbos95
Sep 09 2015 07:43
@marzelin Ah oke. Thank you for taking the time to explain. IT is really appreciated
CamperBot
@camperbot
Sep 09 2015 07:43
mbos95 sends brownie points to @marzelin :sparkles: :thumbsup: :sparkles:
:warning: mbos95 already gave marzelin points
marzelin
@marzelin
Sep 09 2015 07:43
@Mbos95 you're welcome
@Roboteyes remove lines with <!--- and -->
RobotEyes
@Roboteyes
Sep 09 2015 07:44
ok, let me go try it!! Thanks @marzelin
CamperBot
@camperbot
Sep 09 2015 07:44
roboteyes sends brownie points to @marzelin :sparkles: :thumbsup: :sparkles:
:star: 149 | @marzelin | http://www.freecodecamp.com/marzelin
RobotEyes
@Roboteyes
Sep 09 2015 07:46
You're the best @marzelin
Mbos95
@Mbos95
Sep 09 2015 07:55
o = new Object();
o.prop = 'exists';

function changeO() {
  o.newprop = o.prop;
  delete o.prop;
}

o.hasOwnProperty('prop');   // returns true
changeO();
o.hasOwnProperty('prop');   // returns false
Just a little confirmation. In this example at first the property of o is named prop. After that they change the name of prop to newprop. right?
and that is why it is first true and then false, because it looks for prop
Right?
marzelin
@marzelin
Sep 09 2015 07:57
@Mbos95 this line o.prop = 'exists'; assigns value 'exits' to property 'prop' of object o
Avishay
@avishayshushan
Sep 09 2015 07:57
@Mbos95 yes
Mbos95
@Mbos95
Sep 09 2015 07:57
did I just catch the dragon by its tail ?
Avishay
@avishayshushan
Sep 09 2015 07:58
@Mbos95 but changed is not the right term
it is more like created a new property
and deleted the old one
Mbos95
@Mbos95
Sep 09 2015 07:59
So now, the .hasOwnProperty looks for the name of a property, if it exists in the object. But can I also let it check for the content in a property ?
Yes yes, I phrased it wrong! thank you :)
CamperBot
@camperbot
Sep 09 2015 07:59
if you want to thank someone, put an @ before their name!
Mbos95
@Mbos95
Sep 09 2015 08:00
or would I need to use other matters for that ? (as in an if loopdyloop)
marzelin
@marzelin
Sep 09 2015 08:00
@Mbos95 paste your code here http://pythontutor.com/javascript.html#mode=edit and you'll see what's going on in your code step by step
Mbos95
@Mbos95
Sep 09 2015 08:00
hmm oke oke
thank you @marzelin @avishayshushan
CamperBot
@camperbot
Sep 09 2015 08:00
mbos95 sends brownie points to @marzelin and @avishayshushan :sparkles: :thumbsup: :sparkles:
:warning: mbos95 already gave marzelin points
:star: 216 | @avishayshushan | http://www.freecodecamp.com/avishayshushan
Mbos95
@Mbos95
Sep 09 2015 08:12
Hmm I can't seem to get it working..
function where(collection, source) {
  var arr = [];
  for(var i=0;i <collection.length;i++){
   var check = collection.hasOwnProperty('last')

  }
  return check;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
It should check if there are properties called last now,right? and return true if it does
function where(collection, source) {
  var arr = [];
  for(var i=0;i <collection.length;i++){
   var check = collection.hasOwnProperty('last')
    if(check){
      console.log("got a true value")

    }else{
      console.log("false sadly")

    }
  }
  return check;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
function where(collection, source) {
  var arr = [];
  for(var i=0;i <collection.length;i++){
   var check = collection.hasOwnProperty('last')
    if(check){
      arr.push(check);

    }else{
      console.log("false sadly")

    }
  }
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
doesn't evaluate as true sadly
Am I using the hasOwnProperty wrong ?
Mbos95
@Mbos95
Sep 09 2015 08:17
wait wait, got something working!
marzelin
@marzelin
Sep 09 2015 08:18
@Mbos95 collection.hasOwnProperty('last') you try it on the whole collection instead of an item of that collection collection[i].hasOwnProperty('last')
Mbos95
@Mbos95
Sep 09 2015 08:19
yes! I figured that out in the end. stupid mistake! :D
Thank you @marzelin
CamperBot
@camperbot
Sep 09 2015 08:19
mbos95 sends brownie points to @marzelin :sparkles: :thumbsup: :sparkles:
:warning: mbos95 already gave marzelin points
marzelin
@marzelin
Sep 09 2015 08:24
@Mbos95 you should introduce another variable var obj = collection[i] to make the code easier to read. I'll be quite complex code, so it's easy to lost track what is what
Mbos95
@Mbos95
Sep 09 2015 08:24
function where(collection, source) {
  var arr = [];
  for(var i=0;i <collection.length;i++){
   var check = collection[i]
   check.hasOwnProperty('last')
    if(check){
      arr.push(check);

    }else{


    }
  }
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
Hmm I am stuck on how to use this object.keys thing.
It seems like a waste of time(which is probably isn't) to get a return of keys which are random..
Because the keys are just the names of the properties,right? or how does that work? the explanation is a bit lacking on the article provided
marzelin
@marzelin
Sep 09 2015 08:26
@Mbos95 you need to check objects in collection for properties specified in source. Create arrays that store all keys from source
then check each object in collection if values of the keys are the same as in source
Mbos95
@Mbos95
Sep 09 2015 08:27
so I need to make an array which will check the source. This array will incluse the keys of source. after that I need to make a code which will compare source against collection.
Oh oke.. Can you tell me how that works? the values of the keys?
As.. will they be converted into numbers? or.. the keys, what will their content be ?
marzelin
@marzelin
Sep 09 2015 08:28
@Mbos95 what do you know about objects?
Anna Presnyakova
@chiffenok
Sep 09 2015 08:29
Hi guys. I'm working on weather zipline and I have as question. Have question. How to make on js to check if number in certain range and deepens on this returns certain value (without long if statement, and should support negative numbers, I know how to do it without) . Let's say if temperature in the range from -40 to -20 i want to return value 'freezing', from -20 to 0 'cold', from 0 to +10 'chilly', +10 to +20 'warm', , +20 to +30 'hot'. It's just an example but I have this question not first time, so I want to figure out how to do it
Mbos95
@Mbos95
Sep 09 2015 08:29
Hmm.. not a lot I suppose. just the basics :)
That it is basicly an 'variable' that can store lots of things. This includes properties but also functions right?
marzelin
@marzelin
Sep 09 2015 08:30
@Mbos95 object is a set of pairs property: value
Mbos95
@Mbos95
Sep 09 2015 08:30
So you can use object to acces larger amounts of data (and also push new data in at the bottom and such, useful for databases and stuff I imagine)
Roy
@CruelCoin
Sep 09 2015 08:31
Hi guys, i'm having an issue with the MongoDB cloud9 tutorial. I have tried this on two seperate computers to try rule that out, but this is the error i'm getting: ✗ Error connecting to mongo. connect ECONNREFUSED
Any ideas?
Mbos95
@Mbos95
Sep 09 2015 08:33
@chiffenok can't you achieve that by using an if loop?
if(temp > 20 && temp < 30){
  code to return "hot"
}
I am new to this, but this seems like it would work for me at the stage I am at..
marzelin
@marzelin
Sep 09 2015 08:35
@Mbos95 it's like an array but with index no to be numbers from 0...n but names like age origin whatever. these non numeric indexes are also called keys. You can access values on in objects similar to arrays but instead of specifying index you specify key obj['name'] // returns a value of name
Mbos95
@Mbos95
Sep 09 2015 08:36
Oooooh oke.. !
Avishay
@avishayshushan
Sep 09 2015 08:36
@chiffenok you can use case
@chiffenok case temp :
sorry
use switch (temp)
Mbos95
@Mbos95
Sep 09 2015 08:37
@marzelin So keys are just the name of the properties the n
@avishayshushan Oh yea, that is a good idea :) switch will be a good option for this. mine is a bit long winded xD
Anna Presnyakova
@chiffenok
Sep 09 2015 08:37
@Mbos95 yes but it could be very long if, I don't want this, for another example I don't know how much ranges I have, I think it should me more efficient to do it
for example look here: http://stackoverflow.com/questions/7490660/converting-wind-direction-in-angles-to-text-words with if statement it will so much line of codes
Mbos95
@Mbos95
Sep 09 2015 08:38
@chiffenok Yea I can imagine that would not fit the purpose you are trying to use it for! Well now this beats my coding expertise level. :D Good luck :)
Anna Presnyakova
@chiffenok
Sep 09 2015 08:38
@avishayshushan is there any solution with array or object ? like here http://stackoverflow.com/questions/7490660/converting-wind-direction-in-angles-to-text-words
Avishay
@avishayshushan
Sep 09 2015 08:41
@chiffenok you want to put the weather conditions in an array?
or to make a decision with no if/switch?
@chiffenok oh i see what you want
what is the lowest temp? is it -273?
Mbos95
@Mbos95
Sep 09 2015 08:45
@marzelin So I got the keys from both the collection and the source. now I run into the problem that the collection has 2 different keys! first and last. How can I comapre them with each other ? I first need to filter out first-last to be just last. then I need to compare the content of last...
Avishay
@avishayshushan
Sep 09 2015 08:46
maybe conditions[(temp+273)/somthing]
condition will contain - 'freez' 'hot' etc.
something will need to match your criteria
also use round/floor for integer index
Anna Presnyakova
@chiffenok
Sep 09 2015 08:49
@avishayshushan It's just an example to this zipline, I want to know how to do it in general, maybe it will be situation where I need smth similar again, ok got what u mean to make the negative number is positive,
Avishay
@avishayshushan
Sep 09 2015 08:49
@chiffenok conditions[floor((temp+273)%20)]
marzelin
@marzelin
Sep 09 2015 08:50
@Mbos95 you just need to store keys from source and then for each key you check obj in collection if source[key] === objFromCollection[key] is true for all provided keys
Mbos95
@Mbos95
Sep 09 2015 08:51
function where(collection, source) {
  var arr = [];
  var sourcekey = Object.keys(source)
  for(var i=0;i <collection.length;i++){
   var check = collection[i]
   var collectionkey = Object.keys(check)
    if(collectionkey === sourcekey){
      arr.push(check);

    }else{


    }
  }
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
I have this
Anna Presnyakova
@chiffenok
Sep 09 2015 08:51
@avishayshushan that's good, but it'll work only if we know the max negative, and all rages with the same length
Avishay
@avishayshushan
Sep 09 2015 08:52
@chiffenok that is correct, my method is not general
@chiffenok but for a weather app the temp min and max are known
marzelin
@marzelin
Sep 09 2015 08:53
@Mbos95 you don't care about keys, you care about values stored in object[key] - compare values not keys
ronald
@ronstarcool
Sep 09 2015 08:53
how bout a switch?
Mbos95
@Mbos95
Sep 09 2015 08:53
yes but I am not sure how to acces the values.
Anna Presnyakova
@chiffenok
Sep 09 2015 08:54
in some city could -60 , but absolute minus I think more in Kelvin
marzelin
@marzelin
Sep 09 2015 08:54
@Mbos95 object[key]
Mbos95
@Mbos95
Sep 09 2015 08:54
hmm oke
So that will return the name actuall in the certain key
so source['last'] will give me 'Capulet'?
marzelin
@marzelin
Sep 09 2015 08:55
var obj = { first: 'Romeo', last: 'Montague' };
console.log(obj['first']); // returns 'Romeo'
Mbos95
@Mbos95
Sep 09 2015 08:56
Hmm oke oke
Well let me think over it and tinker around with it a bit :)
thank you @marzelin
CamperBot
@camperbot
Sep 09 2015 08:56
mbos95 sends brownie points to @marzelin :sparkles: :thumbsup: :sparkles:
:star: 150 | @marzelin | http://www.freecodecamp.com/marzelin
Mbos95
@Mbos95
Sep 09 2015 08:57
@chiffenok (not that it matters) highest recorded temperature is 86 degrees celcius. Just make it range from -273 to +100 and you'll be set
and I know you want to have the just in general idea without any limitation to the ranges, but I just wanted to help you a bit with the range :)
Anna Presnyakova
@chiffenok
Sep 09 2015 09:03
@Mbos95 if i will take from -273 I#ll not find so much adjectives)) , it's too much
Mbos95
@Mbos95
Sep 09 2015 09:03
aw oke
Anna Presnyakova
@chiffenok
Sep 09 2015 09:03
@Mbos95 it's outstanding example
Mbos95
@Mbos95
Sep 09 2015 09:03
You are now just throwing words at me which I don't get xD
yet.....
googles adjectives
Well, lowest recorded is -90 :)
so -100 to +100 is maybe an good possibility
codedestitute
@codedestitute
Sep 09 2015 09:19
Hi, I saw that you are working on the same bonfire problem as me.
I have something similar that is giving me 2 out of 4 of the tests to pass
Mbos95
@Mbos95
Sep 09 2015 09:22
function where(collection, source) {
  var arr = [];
  var sourcekey = Object.keys(source)
  for(var i=0;i <collection.length;i++){
   var check = collection[i]
   var collectionkey = Object.keys(check)
    if(check[sourcekey] === source[sourcekey]){
      arr.push(check);

    }else{


    }
  }
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
Why doesn't this work ?
It passes the first two tests but not the rest
@codedestitute The same bonfire as me, you mean ? :)
marzelin
@marzelin
Sep 09 2015 09:23
@Mbos95 i see missing comma on line five
codedestitute
@codedestitute
Sep 09 2015 09:23
@Mbos95 yes the same one
Mbos95
@Mbos95
Sep 09 2015 09:23
function where(collection, source) {
  var arr = [];
  var sourcekey = Object.keys(source);
  for(var i=0;i <collection.length;i++){
   var check = collection[i];
   var collectionkey = Object.keys(check);
    if(check[sourcekey] === source[sourcekey]){
      arr.push(check);

    }else{


    }
  }
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
codedestitute
@codedestitute
Sep 09 2015 09:23
I have the first two test passed but I am not even sure what the third and fourth are checking against
Mbos95
@Mbos95
Sep 09 2015 09:24
@codedestitute Yea I have the same problem. I think I got the result right for the fourth one but it doesn't complete
codedestitute
@codedestitute
Sep 09 2015 09:24
i was wondering if it is supposed to check a whole object and not just an individual key for 3 and 4
Anna Presnyakova
@chiffenok
Sep 09 2015 09:25
@Mbos95 you are throwing at me records which I don't care )) I'm not going to google adjectives), it's pointless work, I'm here to learn to code, not to learn "40 adjectives how to describe whether" :smile:
Mbos95
@Mbos95
Sep 09 2015 09:26
@chiffenok You misunderstood me. I didn't know the word, I googled it
marzelin
@marzelin
Sep 09 2015 09:26
@Mbos95 missing comma on line 6 as well, it's working for some cases isn't it?
Mbos95
@Mbos95
Sep 09 2015 09:26
@chiffenok And hey, I know.. just trying to help
@marzelin Yes it is working for the first case. the other 2 it doesn 't work
codedestitute
@codedestitute
Sep 09 2015 09:27
Ah, my page closed and the code didnt save. does anyone know how to get it back?
Mbos95
@Mbos95
Sep 09 2015 09:27
Sadly not :(
function where(collection, source) {
  var arr = [];
  var sourcekey = Object.keys(source);
  for(var i=0;i <collection.length;i++){
   var check = collection[i];
    if(check[sourcekey] === source[sourcekey]){
      arr.push(check);

    }else{


    }
  }
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });
marzelin
@marzelin
Sep 09 2015 09:29
@Mbos95 it works only when there's only one key in source. Chage the code to work for source with more than one key
Avishay
@avishayshushan
Sep 09 2015 09:31
var sourcekey = Object.keys(source)[0];
CamperBot
@camperbot
Sep 09 2015 09:31
:bulb: to format code use backticks! ``` more info
Mbos95
@Mbos95
Sep 09 2015 09:31
ooh oke...

The one i just posted returns "last" when I return the sourcekey.
When I have this

function where(collection, source) {
  var arr = [];
  var sourcekey = Object.keys(source)[1];
  for(var i=0;i <collection.length;i++){
   var check = collection[i];
    if(check[sourcekey] === source[sourcekey]){
      arr.push(check);

    }else{


    }
  }
  return sourcekey;
}

where([{ 'a': 5 }, { 'a': 5 }, { 'a': 5, 'b': 10 }], { 'a': 5, 'b': 10 }), [{ 'a': 5, 'b': 10 }]

It returns [{"a": 5 , "b" : 10}]

it seems to not select the A or B but just thinks.. screw it! I'll just pick the whole source!
Avishay
@avishayshushan
Sep 09 2015 09:35
@Mbos95 are you returning the sourcekey for debug?
cause i think you should return the arr
Soumya Rauth
@soumyaRauth
Sep 09 2015 09:36
Pomodoro seems really tough for me... Should I skip it for now...? Or first finish then jump to other.
Also Any suggestion on why is it not working properly? http://codepen.io/soumya_rauth/pen/PPoZMM
Mbos95
@Mbos95
Sep 09 2015 09:36
@avishayshushan Yes I am returning it for debug to see what isw happening
marzelin
@marzelin
Sep 09 2015 09:36
@Mbos95 it doesn't return source but the last element from collection which happens to be the same as source
Avishay
@avishayshushan
Sep 09 2015 09:36
@Mbos95 ok
Mbos95
@Mbos95
Sep 09 2015 09:37
@marzelin But I am returning sourcekey, which is supposed to be the keys of source object
Avishay
@avishayshushan
Sep 09 2015 09:38
@Mbos95 read a little about hasownproperty
and try to add another condition to the if statement (&&)
marzelin
@marzelin
Sep 09 2015 09:40
@Mbos95 oh i see you changed return. it is that way because you put source object in an array
there were two keys but you just removed second without removing enclosing array
@Mbos95 remove array and it'll return 'b'
Ricardo Nunes
@RicardoJFN
Sep 09 2015 09:43
hi all and good morning. Need help with Show the local weather zipline :worried: . Followed an advice to see simpleweather,js and through there i've followed a tutorial. But it's just as my other atempts...not working. About to loosing my mind over this :P
Mbos95
@Mbos95
Sep 09 2015 09:43
oke, I am all confused now :(

function where(collection, source) {
var arr = [];
var sourcekey = Object.keys(source)1;
for(var i=0;i <collection.length;i++){
var check = collection[i];
if(check[sourcekey][0] === source[sourcekey][0] && checksourcekey === sourcesourcekey){
arr.push(check);

}else{


}

}
return sourcekey;
}

where([{ 'a': 5 }, { 'a': 5 }, { 'a': 5, 'b': 10 }], { 'a': 5, 'b': 10 }), [{ 'a': 5, 'b': 10 }]

function where(collection, source) {
  var arr = [];
  var sourcekey = Object.keys(source)[1];
  for(var i=0;i <collection.length;i++){
   var check = collection[i];
    if(check[sourcekey][0] === source[sourcekey][0] && check[sourcekey][1] === source[sourcekey][1]){
      arr.push(check);

    }
  }
  return sourcekey;
}

where([{ 'a': 5 }, { 'a': 5 }, { 'a': 5, 'b': 10 }], { 'a': 5, 'b': 10 }), [{ 'a': 5, 'b': 10 }]
Avishay
@avishayshushan
Sep 09 2015 09:44
@RicardoJFN what is the first issue?
Mbos95
@Mbos95
Sep 09 2015 09:44
function where(collection, source) {
  var arr = [];
  var sourcekey = Object.keys(source)[1];
  for(var i=0;i <collection.length;i++){
   var check = collection[i];
    if(check[sourcekey][0] === source[sourcekey][0] && check[sourcekey][1] === source[sourcekey][1]){
      arr.push(check);

    }
  }
  return sourcekey;
}

where([{ 'a': 5 }, { 'a': 5 }, { 'a': 5, 'b': 10 }], { 'a': 5, 'b': 10 }), [{ 'a': 5, 'b': 10 }]
Avishay
@avishayshushan
Sep 09 2015 09:45
@Mbos95 what is the returning arr now?
Blauelf
@Blauelf
Sep 09 2015 09:45
This message was deleted
Avishay
@avishayshushan
Sep 09 2015 09:45
try to use (source)[0]
var sourcekey = Object.keys(source)[0];
Mbos95
@Mbos95
Sep 09 2015 09:46
That works!
Blauelf
@Blauelf
Sep 09 2015 09:46
sourcekey is only one key, you should check for multiple keys.
Mbos95
@Mbos95
Sep 09 2015 09:47
but now I can complete the first 2 assignment but not the first 2 anymore xD
function where(collection, source) {
  var arr = [];
  var sourcekey = Object.keys(source)[1];
  for(var i=0;i <collection.length;i++){
   var check = collection[i];
    if(check[sourcekey[0]] === source[sourcekey[0]] && check[sourcekey[1]] === source[sourcekey[1]]){
      arr.push(check);

    }
  }
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' }), [{ first: 'Tybalt', last: 'Capulet' }]
Ah it works now
function where(collection, source) {
  var arr = [];
  var sourcekey = Object.keys(source);
  for(var i=0;i <collection.length;i++){
   var check = collection[i];
    if(check[sourcekey[0]] === source[sourcekey[0]] && check[sourcekey[1]] === source[sourcekey[1]]){
      arr.push(check);

    }
  }
  return arr;
}

where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' }), [{ first: 'Tybalt', last: 'Capulet' }]
finished code! That worked. Thank you all!
CamperBot
@camperbot
Sep 09 2015 09:48
if you want to thank someone, put an @ before their name!
Mbos95
@Mbos95
Sep 09 2015 09:48
Thanks @Blauelf @avishayshushan @marzelin
CamperBot
@camperbot
Sep 09 2015 09:48
mbos95 sends brownie points to @blauelf and @avishayshushan and @marzelin :sparkles: :thumbsup: :sparkles:
:warning: mbos95 already gave marzelin points
:star: 217 | @avishayshushan | http://www.freecodecamp.com/avishayshushan
:star: 271 | @blauelf | http://www.freecodecamp.com/blauelf
Avishay
@avishayshushan
Sep 09 2015 09:49
great! mission accomplished!
Blauelf
@Blauelf
Sep 09 2015 09:50
@Mbos95 If you want to make it work for all numbers of keys, you could try every() or loop over the keys.
Mbos95
@Mbos95
Sep 09 2015 09:50
every?
Can you give me an example of the use of every()?
Blauelf
@Blauelf
Sep 09 2015 09:52
Every is a method of Arrays that checks if the function you give as a parameter evaluates to true for all elements of the array.
Here you could do something like
if (sourcekey.every(function(key){/* return true if equal for both objects, check and source, false if not */}))
  arr.push(check);
Mbos95
@Mbos95
Sep 09 2015 09:55
ooooh oke
Ricardo Nunes
@RicardoJFN
Sep 09 2015 09:57
@avishayshushan ok i think i solved my problem >_< . It has to do with my script src tags
Blauelf
@Blauelf
Sep 09 2015 09:58
every() will call the given function with each of the elements, and if any of the return values evaluates to false, itself return false. It even short-circuits, so stops testing when it is already false. There is an equivalent for 'or', which is any()
Ozy Design & Software
@OzySky
Sep 09 2015 10:00
some() actually
marzelin
@marzelin
Sep 09 2015 10:07
@Mbos95 you can also replace the first loop with for each method
function where(collection, source) {
  var arr = [];
  var sourcekeys = Object.keys(source);
  collection.forEach(function(obj){
    if(sourcekeys.every(function(key){return obj[key]===source[key]})){
      arr.push(obj);
    }
  });
  return arr;
}
Ricardo Nunes
@RicardoJFN
Sep 09 2015 10:12
@avishayshushan ok the problem was the misplaced script tags importing my js file. I was doing the import in the head instead of the body.
Avishay
@avishayshushan
Sep 09 2015 10:13
@RicardoJFN ok
Mbos95
@Mbos95
Sep 09 2015 10:20
Oke, thank you guys :)
CamperBot
@camperbot
Sep 09 2015 10:20
if you want to thank someone, put an @ before their name!
auchomage
@auchomage
Sep 09 2015 10:21
I have a quick question, hopefully it will be obvious to someone where.
AndyDuffy
@AndyDuffy
Sep 09 2015 10:23
bonfire where art thou
CamperBot
@camperbot
Sep 09 2015 10:23

:fire:Bonfire: Where art thou :link:

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

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

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

more info:  bf details | bf links | hint

auchomage
@auchomage
Sep 09 2015 10:24
var result = '', i;
My understanding is that you can only assign one value to a variable, but here are two values being assigned at the same to the variable 'result'? Thanks.
CamperBot
@camperbot
Sep 09 2015 10:24
if you want to thank someone, put an @ before their name!
marzelin
@marzelin
Sep 09 2015 10:26
This message was deleted
@auchomage don't mind the last answer.
it's multiple variable creation. that code is equal to
var result = '';
var i;
auchomage
@auchomage
Sep 09 2015 10:28

@marzelin , thanks for the explanation. I got it from

var repeatString = function(string, n) {
    var result = '', i;

    for (i = 1; i <= n; i *= 2) {
        if ((n & i) === i) {
            result += string;
        }
        string = string + string;
    }

    return result;
};

From this page:
http://stackoverflow.com/questions/1877475/repeat-character-n-times

CamperBot
@camperbot
Sep 09 2015 10:28
auchomage sends brownie points to @marzelin :sparkles: :thumbsup: :sparkles:
:star: 152 | @marzelin | http://www.freecodecamp.com/marzelin
auchomage
@auchomage
Sep 09 2015 10:30
I have a question about debugging using Google Chrome Tools. I can load my script, press F12, select the source tab and create a breakpoint. I can't seem to step through my code. I've tried a variety of F keys, F8, F9, F10, F11 and nothing. Does anyone know a good tutorial for a beginner that walks one through this process? Thanks in advance.
CamperBot
@camperbot
Sep 09 2015 10:30
if you want to thank someone, put an @ before their name!
minakasiin
@minakasiin
Sep 09 2015 10:34
This message was deleted
CamperBot
@camperbot
Sep 09 2015 10:34

:fire:Bonfire: Factorialize a Number :link:

function factorialize(num) {
  return num;
}

factorialize(5);

Return the factorial of the provided integer.

more info:  bf details | bf links | hint

minakasiin
@minakasiin
Sep 09 2015 10:34
bf factorialize | hint
CamperBot
@camperbot
Sep 09 2015 10:34
Sorry, can't find a bonfire called factorialize hint. [ Check the map? ]
marzelin
@marzelin
Sep 09 2015 10:36
@auchomage check out this page http://pythontutor.com/
Blauelf
@Blauelf
Sep 09 2015 10:37
@ozydesign Thanks for the correction, all and any are the pythonic equivalents to every and some, so I sometimes confuse those.
CamperBot
@camperbot
Sep 09 2015 10:37
blauelf sends brownie points to @ozydesign :sparkles: :thumbsup: :sparkles:
:star: 184 | @ozydesign | http://www.freecodecamp.com/ozydesign
auchomage
@auchomage
Sep 09 2015 10:38
@marzelin Thanks for the reference, I will definitely investigate it. I still need to know how to use google chrome debugging tools.
marzelin
@marzelin
Sep 09 2015 10:39
@auchomage i think there are lots of tutorials on youtube about this topic
@auchomage this looks interesting https://www.youtube.com/watch?v=B63jNjSVEbQ
auchomage
@auchomage
Sep 09 2015 10:46
@marzelin There are, I went through several, one talked about extensions, others assumed one knew stuff. I was looking for a generic one for a rank beginner, like myself. I will look at the additional link you provided, thanks again. I have to go now.
CamperBot
@camperbot
Sep 09 2015 10:46
auchomage sends brownie points to @marzelin :sparkles: :thumbsup: :sparkles:
:warning: auchomage already gave marzelin points
Mbos95
@Mbos95
Sep 09 2015 10:47
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Hey, how can I acces the last 2 numbers in destroyer ?
Rory Smith
@alanbuchanan
Sep 09 2015 10:48
@Mbos95 try arguments
Mbos95
@Mbos95
Sep 09 2015 10:49
oooooooh oke
got it :D thank you
CamperBot
@camperbot
Sep 09 2015 10:49
if you want to thank someone, put an @ before their name!
Blauelf
@Blauelf
Sep 09 2015 10:52
Ouch. Just realized why my destroyer solution using filter stopped working after I switched from lambda expressions to real functions. Real functions have their own arguments object.
Rory Smith
@alanbuchanan
Sep 09 2015 10:54
bonfire make a person
CamperBot
@camperbot
Sep 09 2015 10:54

:fire:Bonfire: Make a Person :link:

var Person = function(firstAndLast) {
    return firstAndLast;
};

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

Fill in the object constructor with the methods specified in the tests.

more info:  bf details | bf links | hint

Rory Smith
@alanbuchanan
Sep 09 2015 10:54
this is perplexing me
why would you want someone's full name not to be firstname + lastname?
marzelin
@marzelin
Sep 09 2015 10:55
@alanbuchanan it is like this
Blauelf
@Blauelf
Sep 09 2015 10:55
It is firstname+' '+lastname I think?
Rory Smith
@alanbuchanan
Sep 09 2015 10:57
@Blauelf what i mean is, the test cases require an instantiation of firstname 'happy', lastname 'trees', fullname 'george carlin'
unless i'm completely missing the point (likely)
Blauelf
@Blauelf
Sep 09 2015 10:57
Are you sure?
Rory Smith
@alanbuchanan
Sep 09 2015 10:57
No!
well, i thought i was...
marzelin
@marzelin
Sep 09 2015 10:59
@alanbuchanan there is some code that you don't see in that assertion test
that sets object properties
Rory Smith
@alanbuchanan
Sep 09 2015 11:00
i'm not following
can you explain?
marzelin
@marzelin
Sep 09 2015 11:01
@alanbuchanan before running this test expect(bob.getFullName()).to.eql('George Carlin'); it runs bob.setFullName('George Carlin');
Rory Smith
@alanbuchanan
Sep 09 2015 11:01
ahh
Elliott Maas
@elliottmaas
Sep 09 2015 11:01
i'm on Waypoint: Declare Javascript Variables (104) and for the life of me I can't figure out what the directions are trying to get me to do. i understand the variables when it is like a mathematical function, but in this example i need help!
Rory Smith
@alanbuchanan
Sep 09 2015 11:01
thanks for the tip @marzelin
CamperBot
@camperbot
Sep 09 2015 11:01
alanbuchanan sends brownie points to @marzelin :sparkles: :thumbsup: :sparkles:
:star: 153 | @marzelin | http://www.freecodecamp.com/marzelin
Prashanth
@dgprashanth
Sep 09 2015 11:07
Guys, I have this issue where my js stuff does not load automatically, but if i call it through a click event, it works fine
I have used document.ready and it still doesn't work.. Can anyone help me with it? I will post the codepen link here
Spatz
@Spatzerny
Sep 09 2015 11:11
paste the code
This is the code where nothing loads, I can also post the working code link if you want
(the one where the button click loads the results)
Avishay
@avishayshushan
Sep 09 2015 11:12
@elliottmaas could you add the problem here
i cant find it
Aniruddh Agarwal
@anrddh
Sep 09 2015 11:12
That's because you never call your functions
oh, nvm
Yeah, you never call your getLocation function
Prashanth
@dgprashanth
Sep 09 2015 11:13
@awesomeaniruddh ?? Should I call it through html part?
Aniruddh Agarwal
@anrddh
Sep 09 2015 11:13
Which triggers the rest of the code
Makler
@Makler1337
Sep 09 2015 11:13
121
Aniruddh Agarwal
@anrddh
Sep 09 2015 11:13
Add getLocation() at the end of your code
Prashanth
@dgprashanth
Sep 09 2015 11:13
@awesomeaniruddh Ahh kinda figured that i need to call it somewhere, but didn't know where
at the end of the html? Ok will try that!
Aniruddh Agarwal
@anrddh
Sep 09 2015 11:14
Not HTML
JS
Before the final closing brace (})
Spatz
@Spatzerny
Sep 09 2015 11:14
also, asynchronous calls one after the other
Aniruddh Agarwal
@anrddh
Sep 09 2015 11:14
for the document.ready() function
Avishay
@avishayshushan
Sep 09 2015 11:15
@dgprashanth you can also call it from the html
using onload
Prashanth
@dgprashanth
Sep 09 2015 11:15
@awesomeaniruddh Got it! Thanks! Been cracking my head over that for nothing it seems :smile:
CamperBot
@camperbot
Sep 09 2015 11:15
dgprashanth sends brownie points to @awesomeaniruddh :sparkles: :thumbsup: :sparkles:
Avishay
@avishayshushan
Sep 09 2015 11:15
<body onload="getLocation()">
CamperBot
@camperbot
Sep 09 2015 11:15
:star: 388 | @awesomeaniruddh | http://www.freecodecamp.com/awesomeaniruddh
Prashanth
@dgprashanth
Sep 09 2015 11:15
@avishayshushan Oh thanks! That will also be a useful hint for me to remember :D
CamperBot
@camperbot
Sep 09 2015 11:15
dgprashanth sends brownie points to @avishayshushan :sparkles: :thumbsup: :sparkles:
:star: 220 | @avishayshushan | http://www.freecodecamp.com/avishayshushan
Prashanth
@dgprashanth
Sep 09 2015 11:16
@Spatzerny I don't understand what that means.. Should I be splitting the code into smaller functions?
Spatz
@Spatzerny
Sep 09 2015 11:16
json
oh nvm
you dont actually use the data from the first one in the second one
if you'd use city from the first call while checking for the weather in city it would probably fail
Prashanth
@dgprashanth
Sep 09 2015 11:18
Oh..
Spatz
@Spatzerny
Sep 09 2015 11:18
because asynchronous basically means that it doesnt wait
Prashanth
@dgprashanth
Sep 09 2015 11:19
then i would have had to call the function outside of document.ready is it?
Spatz
@Spatzerny
Sep 09 2015 11:19
no
you'd just have to call the second JSON request inside the function of the first one
Prashanth
@dgprashanth
Sep 09 2015 11:21
Ah... Alright!
Spatz
@Spatzerny
Sep 09 2015 11:21
it's basically 'go get something and when you get it do thing'
'but in the meantime lets continue'
so thing will happen once you get a response from the API
and in the meantime the code is doing its thing ahead
Makler
@Makler1337
Sep 09 2015 11:25
:link:

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

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

.red-text {
color: red;
}

h2 {
font-family: Lobster, Monospace;
}

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

</style>

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

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

anyone can tell me whats wro with my code
Aniruddh Agarwal
@anrddh
Sep 09 2015 11:26
@Makler1337 wiki format
wiki format
CamperBot
@camperbot
Sep 09 2015 11:26

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Aniruddh Agarwal
@anrddh
Sep 09 2015 11:26
@Makler1337 ^
Makler
@Makler1337
Sep 09 2015 11:26
thanks
CamperBot
@camperbot
Sep 09 2015 11:26
if you want to thank someone, put an @ before their name!
Mbos95
@Mbos95
Sep 09 2015 11:42
Guys, may I ask why this is sorted this way? It doesn 't make any sense!
function where(arr, num) {
  var newarray = [];


   for(var i = 0; i < arr.length; i++){
       newarray.push(arr[i])
      while(arr.length === newarray.length){
        newarray.push(num)
        newarray.sort();

      }



     }
return newarray;
  }



where([2, 5, 10], 15);
Aniruddh Agarwal
@anrddh
Sep 09 2015 11:43
@Mbos95 Which BF?
Mbos95
@Mbos95
Sep 09 2015 11:43
bonfire where do i belong
CamperBot
@camperbot
Sep 09 2015 11:43

:fire:Bonfire: Where do I belong :link:

function where(arr, num) {
  // Find my place in this sorted array.
  return num;
}

where([40, 60], 50);

Return the lowest index at which a value (second argument) should be inserted into a sorted array (first argument).

more info:  bf details | bf links | hint

Mbos95
@Mbos95
Sep 09 2015 11:43
bf details
CamperBot
@camperbot
Sep 09 2015 11:43

:fire:Bonfire: Where do I belong :link:

function where(arr, num) {
  // Find my place in this sorted array.
  return num;
}

where([40, 60], 50);
Return the lowest index at which a value (second argument) should be inserted into a sorted array (first argument).
For example, where([1,2,3,4], 1.5) should return 1 because it is greater than 1 (0th index), but less than 2 (1st index).
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.
links:
Mbos95
@Mbos95
Sep 09 2015 11:44
I am pretty sure it doesn't, since I di d
Aniruddh Agarwal
@anrddh
Sep 09 2015 11:44
What makes no sense @Mbos95?
Mbos95
@Mbos95
Sep 09 2015 11:44
ah the stupid unicode thing
marzelin
@marzelin
Sep 09 2015 11:45
@Mbos95 yep, provide compare function for numbers
Mbos95
@Mbos95
Sep 09 2015 11:45
I glossed through that part :D sorry
Aniruddh Agarwal
@anrddh
Sep 09 2015 11:47
@Mbos95 please fix your indentation from next time onwards!
Mbos95
@Mbos95
Sep 09 2015 11:47
Yea, sorry xD
Aniruddh Agarwal
@anrddh
Sep 09 2015 11:47
My eyes can't focus when I see such butchered code :P
Mbos95
@Mbos95
Sep 09 2015 11:48
xDxD
Mbos95
@Mbos95
Sep 09 2015 11:54
function where(arr, num) {
  var newarray = [];    
   for(var i = 0; i < arr.length; i++){
       newarray.push(arr[i])
      while(arr.length === newarray.length){
        newarray.push(num)
        newarray.sort(function(a,b){
          return a-b;});
      }
     }
return newarray.indexOf(num);
}
where([2, 5, 10], 15);
@awesomeaniruddh You like this? ^^
it is better as before :D
and it works btw. thanks guys!
CamperBot
@camperbot
Sep 09 2015 11:54
if you want to thank someone, put an @ before their name!
Aniruddh Agarwal
@anrddh
Sep 09 2015 11:55
hehe
:D
the closing brace for the for loop is a bit off ;)
Mbos95
@Mbos95
Sep 09 2015 11:56
o.0 it is!
Aniruddh Agarwal
@anrddh
Sep 09 2015 11:56
and so it the last return statement :P
Dhananjay Mehrotra
@dj8923
Sep 09 2015 11:56
how to have this black scrren as background
Mbos95
@Mbos95
Sep 09 2015 11:56
shh!
Dhananjay Mehrotra
@dj8923
Sep 09 2015 11:56
while asking for code?
Aniruddh Agarwal
@anrddh
Sep 09 2015 11:56
wiki format
CamperBot
@camperbot
Sep 09 2015 11:56

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

Aniruddh Agarwal
@anrddh
Sep 09 2015 11:56
@dj8923
Dhananjay Mehrotra
@dj8923
Sep 09 2015 12:00
function where(arr, num) {
  // Find my place in this sorted array.
  arr = arr.sort();
  for (var i = 0; i < arr.length; i++) {
      if (num >= arr[i] && num <= arr[i+1] ) {
          console.log(i+1);
      }
  };
  return num;
}
Blauelf
@Blauelf
Sep 09 2015 12:00
@Mbos95 So what you are doing is equivalent to
function where(arr, num) {
  var newarray = arr.slice();    
  newarray.push(num);
  newarray.sort((a,b)=>a-b);
  return newarray.indexOf(num);
}
where([2, 5, 10], 15);
Dhananjay Mehrotra
@dj8923
Sep 09 2015 12:01
this is the bonfire Where do I belong can anyone help me??
where i am wrong?
Mbos95
@Mbos95
Sep 09 2015 12:01
@Blauelf I suppose yes. :)
Dhananjay Mehrotra
@dj8923
Sep 09 2015 12:02
function where(arr, num) {
  // Find my place in this sorted array.
  arr = arr.sort();
  for (var i = 0; i < arr.length; i++) {
      if (num >= arr[i] && num <= arr[i+1] ) {
          console.log(i+1);
      }
  };
  return num;
}

where([40, 60], 50);
my 2nd and 3rd test case is failing
Aniruddh Agarwal
@anrddh
Sep 09 2015 12:03
@Blauelf @Mbos95
function where(arr, num) {
   return arr.slice().concat(num).sort().indexOf(num);
};
Mbos95
@Mbos95
Sep 09 2015 12:03
stop it! xD
Blauelf
@Blauelf
Sep 09 2015 12:04
That should not work. IIRC push returns the length of the array, so is not chainable.
Mbos95
@Mbos95
Sep 09 2015 12:04
you can't imagine how much brain capacity it took me to make that monster of a code
it is magnificent
Aniruddh Agarwal
@anrddh
Sep 09 2015 12:04
@Blauelf damn
Blauelf
@Blauelf
Sep 09 2015 12:04
You could, however, chain concat.
Aniruddh Agarwal
@anrddh
Sep 09 2015 12:05
Frantically edits code
Mbos95
@Mbos95
Sep 09 2015 12:05
but where is the compare function ?
Blauelf
@Blauelf
Sep 09 2015 12:06
The compare function is needed here, since these are no strings.
function where(arr, num) {
  return arr.concat(num).sort((a,b)=>a-b).indexOf(num);
}
works. I would not have expected concat to work with non-arrays.
@awesomeaniruddh If you do concat, you don't need to slice, since it does not alter the array, and returns a copy instead.
Aniruddh Agarwal
@anrddh
Sep 09 2015 12:10
Damn
:sighs:
Mbos95
@Mbos95
Sep 09 2015 12:10
gives @awesomeaniruddh a rice cookie\
to soften the stress
gives @Blauelf also a rice cookie
I am hungry at work, sorry
Blauelf
@Blauelf
Sep 09 2015 12:13

Another solution could be

function where(arr, num) {
  return arr.reduce((a,b)=>a+(b<num),0);
}

Oh how I love map and reduce :D

Thanks @Mbos95 for that cookie, I could need it :)
CamperBot
@camperbot
Sep 09 2015 12:15
blauelf sends brownie points to @mbos95 :sparkles: :thumbsup: :sparkles:
:star: 196 | @mbos95 | http://www.freecodecamp.com/mbos95
Aniruddh Agarwal
@anrddh
Sep 09 2015 12:15
I hate reduce
Rory Smith
@alanbuchanan
Sep 09 2015 12:15
@Blauelf what's => doing there?
Aniruddh Agarwal
@anrddh
Sep 09 2015 12:15
ES6 @alanbuchanan
Rory Smith
@alanbuchanan
Sep 09 2015 12:16
ah...i had assumed so
Mbos95
@Mbos95
Sep 09 2015 12:16
e-sports 6?
but in all seriousness, what is es6?
Rory Smith
@alanbuchanan
Sep 09 2015 12:16
i still can't figure out
bonfire make a person
CamperBot
@camperbot
Sep 09 2015 12:16

:fire:Bonfire: Make a Person :link:

var Person = function(firstAndLast) {
    return firstAndLast;
};

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

Fill in the object constructor with the methods specified in the tests.

more info:  bf details | bf links | hint

Rory Smith
@alanbuchanan
Sep 09 2015 12:17
var Person = function(firstAndLast) {
    var firstName;
    var lastName;
    var fullName;

    this.getFirstName = function(){
         return this.firstName;
    }
    this.getLastName = function(){
         return this.lastName;     
    }
    this.getFullName = function(){
         return this.fullName;
    }
    this.setFirstName = function(first){
          this.firstName = first;
    }
    this.setLastName = function(last){
         this.lastName = last;     
    }
    this.setFullName = function(firstAndLast){
          this.fullName = firstAndLast;
    }
};

var bob = new Person('Bob Ross');
Screen Shot 2015-09-09 at 13.17.15.png
Aniruddh Agarwal
@anrddh
Sep 09 2015 12:17
@Mbos95 EcmaScript 6
marzelin
@marzelin
Sep 09 2015 12:17
@alanbuchanan remove this
Fábio Paraíso Oliveira
@FabioParaiso
Sep 09 2015 12:17
Hello all. Could you help me with this:
Aniruddh Agarwal
@anrddh
Sep 09 2015 12:18
@Mbos95 It's the new and improved JavaScript
Blauelf
@Blauelf
Sep 09 2015 12:18
@Mbos95 ES6 or ES2015 is relatively new and introduces arrow functions, basically a little bit simpler and shorter than regular functions.
Rory Smith
@alanbuchanan
Sep 09 2015 12:18
@marzelin from where?
Fábio Paraíso Oliveira
@FabioParaiso
Sep 09 2015 12:18
function convert(str) {
  var corr = {"&":"&(amp|AMP|#x00026|#38);"}

  for (chr in corr) {
    var re = new RegExp(chr,"gim")
    str = str.replace(re,corr[chr])
  }

  return "/" + str + "/";
}

convert('Dolce & Gabbana');
marzelin
@marzelin
Sep 09 2015 12:18
@alanbuchanan everywhere
Fábio Paraíso Oliveira
@FabioParaiso
Sep 09 2015 12:19
bf Convert HTML Entities
CamperBot
@camperbot
Sep 09 2015 12:19

:fire:Bonfire: Convert HTML Entities :link:

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

convert('Dolce & Gabbana');

Convert the characters "&", "<", ">", '"' (double quote), and "'" (apostrophe), in a string to their corresponding HTML entities.

more info:  bf details | bf links | hint

Rory Smith
@alanbuchanan
Sep 09 2015 12:19
@marzelin
Program Execution FailureNo user tests were run.
@Blauelf on what platform are you writing ES2015?
Blauelf
@Blauelf
Sep 09 2015 12:20
firstName, lastName and fullName should not have this in front, the functions should.
marzelin
@marzelin
Sep 09 2015 12:20
@alanbuchanan assign proper values to variables you created at the beggining of the object
Blauelf
@Blauelf
Sep 09 2015 12:21
@alanbuchanan Many platforms are adding support with babel, you can even use it on FCC.
Rory Smith
@alanbuchanan
Sep 09 2015 12:22
@Blauelf does it compile to non-ES2015 or something?
Blauelf
@Blauelf
Sep 09 2015 12:23
@alanbuchanan I guess so, as the underlying service does not fully understand ES2015.
Mbos95
@Mbos95
Sep 09 2015 12:24
@Blauelf but who does?
Rory Smith
@alanbuchanan
Sep 09 2015 12:24
@marzelin that was it. damn this was confusing
just when i think i've understood this, i realise i totally don't
marzelin
@marzelin
Sep 09 2015 12:25
@alanbuchanan
something like this
var Person = function(firstAndLast) {
    var firstName = firstAndLast.split(" ")[0];
    var lastName = firstAndLast.split(" ")[1];
    var fullName = firstAndLast;

    this.getFirstName = function(){
         return firstName;
    }
    this.getLastName = function(){
         return lastName;     
    }
    this.getFullName = function(){
         return fullName;
    }
    this.setFirstName = function(first){
          firstName = first;
    }
    this.setLastName = function(last){
         lastName = last;     
    }
    this.setFullName = function(firstAndLast){
          fullName = firstAndLast;
    }

};

var bob = new Person('Bob Ross');
Rory Smith
@alanbuchanan
Sep 09 2015 12:25
this makes a property public, right? and without it it's private?
@marzelin surely you can just do this?
    var firstName = 'Bob';
    var lastName = 'Ross';
    var fullName = 'Bob Ross';
seeing as the values are intended to change with the (invisible) tests
Blauelf
@Blauelf
Sep 09 2015 12:26
@Mbos95 Most browsers already have some support for ES2015. Firefox and Chrome seem to accept it.
Mbos95
@Mbos95
Sep 09 2015 12:26
@Blauelf I ment it as a joke, who fully understands it anyways :D
marzelin
@marzelin
Sep 09 2015 12:28
@alanbuchanan it would pass the tests but it isn't correct according to what it supposed to do.
Rory Smith
@alanbuchanan
Sep 09 2015 12:28
looks like chrome even has some support for ES7
@Blauelf @marzelin this before a property means it's public, and without it's private, right?
marzelin
@marzelin
Sep 09 2015 12:32
@alanbuchanan sort of like that. JavaScript has weird parts though.
minakasiin
@minakasiin
Sep 09 2015 12:32
Anyone would like to help me a little with bonfire: Factorialize a number?
CamperBot
@camperbot
Sep 09 2015 12:32
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Rory Smith
@alanbuchanan
Sep 09 2015 12:33
@marzelin i think i'll only fully understand OO javascript when someone explains it to me like i'm a 5 year old
Mbos95
@Mbos95
Sep 09 2015 12:34
@alanbuchanan You should try to understand it as best as possible and make sure the first language your child will speak will be Javascript
not even english
or your native tongue
Rory Smith
@alanbuchanan
Sep 09 2015 12:34
:smile:
Mbos95
@Mbos95
Sep 09 2015 12:35
in school .."Ummm, sir.. It seems like your child is only trying to make for loops and iterate through arrays of data. We just handed him a book and he is trying to sort all the data into certain ways and everything o.0"
Blauelf
@Blauelf
Sep 09 2015 12:36
@alanbuchanan If you use this.variable, it is added as an attribute/method of the object that is used as this, if you specify it with var, it is bound to the current context, and not valid outside.
Mbos95
@Mbos95
Sep 09 2015 12:36
not sure how it would work, teaching someone whom can't speak to use java.. but hey :)
Rory Smith
@alanbuchanan
Sep 09 2015 12:36
'He says console dot log before he says anything else'
Mbos95
@Mbos95
Sep 09 2015 12:37
xDxDxD
and prompt before any questions xD
marzelin
@marzelin
Sep 09 2015 12:37
@alanbuchanan thing is objects in JavaScript aren't really objects - they are hash tables. And there are closures meaning functions remember their parent's variables.
Fábio Paraíso Oliveira
@FabioParaiso
Sep 09 2015 12:39
function convert(str) {
  var corr = {"&":"&(amp|AMP|#x00026|#38);"}

  for (chr in corr) {
    var re = new RegExp(chr,"gim")
    str = str.replace(re,corr[chr])
  }

  return "/" + str + "/";
}

convert('Dolce & Gabbana');
what am I doing wrong? seems is not passing the tests =S
sandaruwankodi
@sandaruwankodi
Sep 09 2015 12:40
hello friends
Blauelf
@Blauelf
Sep 09 2015 12:40
This can give wonderful memory leaks, if an inner function used as a callback references a field of a large object in one of its outer function, and garbage collector cannot kill it as it is still referenced :D
sandaruwankodi
@sandaruwankodi
Sep 09 2015 12:41
I want a answer for "Create a Set of Radio Buttons" lesson
Blauelf
@Blauelf
Sep 09 2015 12:41
@FabioParaiso It should be &amp;, not all of the four versions.
Mbos95
@Mbos95
Sep 09 2015 12:41
this sounds like an weird episode of an detective serie
sandaruwankodi
@sandaruwankodi
Sep 09 2015 12:41
I want a answer for "Create a Set of Radio Buttons" lesson
Fábio Paraíso Oliveira
@FabioParaiso
Sep 09 2015 12:42
dammit! lol I had that doubt. It was not making sense to me. Thank you @Blauelf
CamperBot
@camperbot
Sep 09 2015 12:42
fabioparaiso sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 273 | @blauelf | http://www.freecodecamp.com/blauelf
minakasiin
@minakasiin
Sep 09 2015 12:42
@sandaruwankodi what kind of answer? is it not working for you?
sandaruwankodi
@sandaruwankodi
Sep 09 2015 12:42
yes
"Each of your two radio button elements should be nested in a label element." this is not complete
minakasiin
@minakasiin
Sep 09 2015 12:43
Can you copy your code? And copy them between these: ```
sandaruwankodi
@sandaruwankodi
Sep 09 2015 12:43
<label><input type="radio" name="indoor-outdoor"> Indoor
<input type="radio" name="indoor-outdoor">outdoor</label>.
Blauelf
@Blauelf
Sep 09 2015 12:43
@FabioParaiso You should learn Regular Expressions, the part with (a|b|c) is meant to match on any of those.
sandaruwankodi
@sandaruwankodi
Sep 09 2015 12:44
@minakasiin
<label><input type="radio" name="indoor-outdoor"> Indoor
<input type="radio" name="indoor-outdoor">outdoor</label>.
minakasiin
@minakasiin
Sep 09 2015 12:45
You only have 1 label element, but you need 2 I believe. @sandaruwankodi
Rory Smith
@alanbuchanan
Sep 09 2015 12:46
This can give wonderful memory leaks, if an inner function used as a callback references a field of a large object in one of its outer function, and garbage collector cannot kill it as it is still referenced :D
@Blauelf can you provide an example of this?
sandaruwankodi
@sandaruwankodi
Sep 09 2015 12:46
@minakasiin thank u very much
CamperBot
@camperbot
Sep 09 2015 12:46
sandaruwankodi sends brownie points to @minakasiin :sparkles: :thumbsup: :sparkles:
:star: 181 | @minakasiin | http://www.freecodecamp.com/minakasiin
minakasiin
@minakasiin
Sep 09 2015 12:47
You are welcome =)
sandaruwankodi
@sandaruwankodi
Sep 09 2015 12:47
@minakasiin are you on facebook?
georgiel
@georgiel
Sep 09 2015 12:47
@georgiel
I know actionscript is a bit outdated cause html5 can do everything it can now.
but, I need it for my course, reccomend a good place to learn it?
Fábio Paraíso Oliveira
@FabioParaiso
Sep 09 2015 12:52
@Blauelf passed last night reading about those. But really dumb on my part not realizing that the solution was being compared with a regular expression. Tkx again =)
Blauelf
@Blauelf
Sep 09 2015 12:52
@alanbuchanan Simply make a large object and add some callback referencing a single field of it, for example in jQuery. Do this repeatedly and your browser will crash the tab. There are workarounds for that, simply by using another variable to hold only the content necessary. There are more ways to create memory leaks, though.
sandaruwankodi
@sandaruwankodi
Sep 09 2015 12:53
Learn software engineering for free>>>http://sh.st/vXg5s
Rory Smith
@alanbuchanan
Sep 09 2015 12:54
@sandaruwankodi we are already...that's why we're in free code camp
Blauelf
@Blauelf
Sep 09 2015 12:58
@FabioParaiso You do not even need to use regular expressions for searching for a single character. And it is not the best idea to do this replace stuff, as it could be that you replace things inside replacement text (would happen if &->& was not done first). You could also do return str.split('').map(x=>corr[x]||x).join('');, which touches every character exactly once.
Sebastian Hewelt
@sebhewelt
Sep 09 2015 13:05
hey, i read the w3schools docs but couldn't find what does this " var string = (str+'') " do?
Blauelf
@Blauelf
Sep 09 2015 13:06
If you add an empty string, this is basically a conversion to string.
Just like unary operator + can be used to convert to numbers: +'3.14'==3.14, or !! can be used to convert to boolean.
Rory Smith
@alanbuchanan
Sep 09 2015 13:09
@Blauelf does ES2015 use strict mode by default?
Sebastian Hewelt
@sebhewelt
Sep 09 2015 13:10

That's what i was assuming, so how these methods work on given string if these are array methods?
function palindrome(str) {
var string = (str+'').replace(/[.,-\/#!$%\^&*;:{}=?-_`~\ ()]/g,"").replace(/\s/g, "").toLowerCase();
return string === (string.split('').reverse().join(''));
}

palindrome("eye");

i.e. .reverse method. I found it in array's methods
Blauelf
@Blauelf
Sep 09 2015 13:11
@alanbuchanan don't know... I just use it, and the basic features work as expected in many environments.
Rory Smith
@alanbuchanan
Sep 09 2015 13:13
@Blauelf just trying it out here and it initiates with use strict
Blauelf
@Blauelf
Sep 09 2015 13:13
@sebastianhew Probably the +'' part was added to convert anything to string, if it is entered for example as a number, which obviously has no replace function.
Should not change anything with the given test cases.
Fábio Paraíso Oliveira
@FabioParaiso
Sep 09 2015 13:15
@Blauelf that is just beautiful code lol And i get what you are saying, I could have a lot of problems.
@Blauelf Question then do you really need the ||x part? wouldn't you just need the x =>corr[x]
Blauelf
@Blauelf
Sep 09 2015 13:18
@FabioParaiso If corr does not contain x, corr[x] is undefined, this is a falsey value, so the expression gets the value of the second expression, which is x.
Ugly Javascript shortcircuit thingy :D
Fábio Paraíso Oliveira
@FabioParaiso
Sep 09 2015 13:19
@Blauelf aha! Quite cleaver! Thank you once again!
CamperBot
@camperbot
Sep 09 2015 13:19
fabioparaiso sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: fabioparaiso already gave blauelf points
Fábio Paraíso Oliveira
@FabioParaiso
Sep 09 2015 13:19
Yup but now i know =P
Blauelf
@Blauelf
Sep 09 2015 13:19
Without the ||x, you would get many undefineds in your string.
Fábio Paraíso Oliveira
@FabioParaiso
Sep 09 2015 13:20
and I wold have a great headache lol Like this i can even see the ones that don't have a corresponding value =)
*would
Dhananjay Mehrotra
@dj8923
Sep 09 2015 13:23
[5, 3, 20, 3].sort(); //output [20, 3, 3, 5] i was expecting [3,3,5,20]....can someone explain
Elizabeth Hatleli
@TheHighPriestess
Sep 09 2015 13:23

Is this a correct "if" statement?

if ((word[0] != "a") || (word[0] != "i") || (word[0] != "e") || (word[0] != "o") || (word[0] != "u"))

Blauelf
@Blauelf
Sep 09 2015 13:23
@dj8923 The numbers are converted to strings. Use .sort(function(a,b){return a-b})
Albert Pedrola
@apedrolam
Sep 09 2015 13:24
'//Use map to add three to each value in the array
var array = [1,2,3,4,5];
// Only change code below this line.
array.map(function(val) {
return val + 3;
});'
what's wrong?¿
Blauelf
@Blauelf
Sep 09 2015 13:24
@TheHighPriestess It is correct, and will always evaluate to true.
Dhananjay Mehrotra
@dj8923
Sep 09 2015 13:24
@Blauelf but if i do [5,4,3,8,9,1].sort(); then answer is coming right
Blauelf
@Blauelf
Sep 09 2015 13:25
@dj8923 Yeah, as these all have the same number of digits.
But '9'>'10' :P
@apedrolam You forgot the return before array.map...
Dhananjay Mehrotra
@dj8923
Sep 09 2015 13:26
so u mean whatever digit i give graeater than 9...mean 2 digit it will be a string...right? @Blauelf
Ginger
@glk101
Sep 09 2015 13:26
hello everyone, have a quick nooblet question
Blauelf
@Blauelf
Sep 09 2015 13:27
@dj8923 Standard algorithm will always convert to string, and compare first 'letter', then second, then third.
Albert Pedrola
@apedrolam
Sep 09 2015 13:27
@Blauelf Thanks!
CamperBot
@camperbot
Sep 09 2015 13:27
apedrolam sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 274 | @blauelf | http://www.freecodecamp.com/blauelf
Dhananjay Mehrotra
@dj8923
Sep 09 2015 13:28
@Blauelf Standard algorithm here means of sort() ??
Blauelf
@Blauelf
Sep 09 2015 13:29
Yeah, if you don't specify a compare function.
Ginger
@glk101
Sep 09 2015 13:30
is it possible to have more than one class object on an element? I'm doing a beginner lesson where I'm supposed to have 2 class objects on an img element but I don't remember how to do multiple classes on the same element.