These are chat archives for FreeCodeCamp/Help

20th
Jul 2017
just1witness
@just1witness
Jul 20 2017 00:31
.testing
Murshid Hassen
@MurshidMac
Jul 20 2017 01:15
hi newbie. Is there a way to install eslint in to my VSCODE. I tried with this but couldn't make it up https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
Scott Rhoades
@srhoades
Jul 20 2017 01:19
trying to update a onClick method for all of a class that have a current onClick. I tried if ($('.box').attr('onClick') != undefined) { console.log("removing player permissions"); $('.box').attr("onClick","cpuTurn())"); } but it is evaluating false due to only some of the box class having an onCLick. Do I have to call each element individually?
CamperBot
@camperbot
Jul 20 2017 01:19
:bulb: to format code use backticks! ``` more info
Ian Gresham
@iangresham
Jul 20 2017 01:29
Hi, I'm new to the forum and haven't done many code projects yet. Anyways, I created this simple page to practice regular expressions, and I'm having problems with the last test pattern, it seems to find a four digit number that's not in the original string.
https://codepen.io/iangresham/pen/zzyevY
Gary
@bluefishmarine
Jul 20 2017 01:30
@iangresham have you tried this website? http://regexr.com/
Ian Gresham
@iangresham
Jul 20 2017 01:32
well, that would have sure saved me some time in creating a page to learn to use regex in, but it's probably better I struggled with it a bit since it helped me to become more comfortable coding (code every day)
Gary
@bluefishmarine
Jul 20 2017 01:34
@iangresham of course. It's always good to practice on your own. I just found this to be very helpful in understanding how some of the options work, because I was confused about a few things in the documentation
Ian Gresham
@iangresham
Jul 20 2017 01:35
I found it now, weird that it went back to the prev. number.
that helped, I just didn't see it yet. Thanks for the help.
Gary
@bluefishmarine
Jul 20 2017 01:35
:+1:
Aidan
@AidanPendergrast
Jul 20 2017 03:08
Hey
I need some help with something

<div class="container-fluid">
  <h3 class="text-primary text-center">jQuery Playground</h3>
  <div class="row">
    <div class="col-xs-6">


    </div>
    <div class="col-xs-6">

    </div>
  </div>
</div>
"Add a div element with the class well inside each of your div elements with the class "col-xs-6""
nevermind, I got it...
Ian Gresham
@iangresham
Jul 20 2017 03:10
</div class="well">
Gregory Cheng
@gregorytcheng
Jul 20 2017 03:23
Currently running into an issue with my weather app. My Open Weather App API call works when I type it into my browser, but it isn’t working in my website: https://codepen.io/gregorytcheng/pen/jwWPPW
Whether or not I use http://, I’m running into the same issue.
Claudio Restifo
@Marmiz
Jul 20 2017 03:42
@gregorytcheng your link is incorrect... you either have a 404 into codepen or a 501 if you try the link directly
Claudio Restifo
@Marmiz
Jul 20 2017 03:44
@gregorytcheng this one looks good. any error in the console in codepen?
anyway openweather and codepen don't play well together.
You probably are better switching api
Some campers has set up this to avoid CORS issues:
https://fcc-weather-api.glitch.me/
Gregory Cheng
@gregorytcheng
Jul 20 2017 03:46
@Marmiz I’m putting the same thing into my codepen app. But it doesn’t seem to be working out. My console reports a 404 error
Claudio Restifo
@Marmiz
Jul 20 2017 03:46
Or switch to an https api like DarkSky
Gregory Cheng
@gregorytcheng
Jul 20 2017 03:46
I’ll try the FCC Weather API
Claudio Restifo
@Marmiz
Jul 20 2017 03:47
@gregorytcheng you had a 404 bc your string was formatted incorrectly, but even with a working link you still have CORS error. Switch API :)
Gregory Cheng
@gregorytcheng
Jul 20 2017 03:48
@Marmiz the FCC API works! Thanks for the help. I wish this was on the main freecodecamp website for everyone to see. Would have saved me a lot of time.
CamperBot
@camperbot
Jul 20 2017 03:48
gregorytcheng sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
:star2: 1003 | @marmiz |http://www.freecodecamp.com/marmiz
Claudio Restifo
@Marmiz
Jul 20 2017 03:49

@gregorytcheng it's on the main page ;)
https://www.freecodecamp.org/challenges/show-the-local-weather

maybe you started the challenge before they updated the description... unlucky but happens

there was tons of discussion on this challenge in the past weeks
Gregory Cheng
@gregorytcheng
Jul 20 2017 03:50
Yeah, I started working on it about a month ago. Since then I’ve moved to New York for an internship so I haven’t had the time to look at it again until this afternoon.
Claudio Restifo
@Marmiz
Jul 20 2017 03:51
Oh well, gl with your internship and happy coding
:+1:
Huỳnh Trần Khanh
@khanh2003
Jul 20 2017 03:51
Quick question: Do you use ESLint?
Claudio Restifo
@Marmiz
Jul 20 2017 03:53
yep
Viktor Tiutiun
@vittorioVT
Jul 20 2017 04:43
hello everybody
heroiczero
@heroiczero
Jul 20 2017 04:43
Hello
Viktor Tiutiun
@vittorioVT
Jul 20 2017 04:43
@heroiczero hi
shivam gupta
@shivamg11000
Jul 20 2017 05:19
to lean redux or flux first
Ajith Asokan
@ajith1994
Jul 20 2017 05:22
Hello
When I toggle bootstrap's carousel, the page is scrolling on its own vertically
https://codepen.io/ajith1994/pen/EXeLVj/?editors=1100
can anyone help me with this?
Viktor Tiutiun
@vittorioVT
Jul 20 2017 05:26
@shivamg11000 flux
shivam gupta
@shivamg11000
Jul 20 2017 05:27
well I got the flux architecture, any good tutorial for learning how to use it
@vittorioVT
Viktor Tiutiun
@vittorioVT
Jul 20 2017 05:28
@shivamg11000 here is written about the technology of flux
shivam gupta
@shivamg11000
Jul 20 2017 05:30
@vittorioVT thanks I will look at it
CamperBot
@camperbot
Jul 20 2017 05:30
shivamg11000 sends brownie points to @vittoriovt :sparkles: :thumbsup: :sparkles:
:cookie: 792 | @vittoriovt |http://www.freecodecamp.com/vittoriovt
Viktor Tiutiun
@vittorioVT
Jul 20 2017 05:30
@shivamg11000 welcome
Alex
@cyberpunk1971
Jul 20 2017 05:38
can someone tell me what a webkit is and when/why/how I would use it/them?
rushendra
@rushendrarushi
Jul 20 2017 05:41
for (var i=0; i>0; i++){
myArray.push(i)}
why do we need to use push ?
Viktor Tiutiun
@vittorioVT
Jul 20 2017 05:43
@rushendrarushi (var i=0; i<arr.length; i++)
rushendra
@rushendrarushi
Jul 20 2017 05:43
no no @vittorioVT i'm just asking why do we need to use push in the above code
Viktor Tiutiun
@vittorioVT
Jul 20 2017 05:44
@rushendrarushi It adds all the elements sequentially to the end of the array
rushendra
@rushendrarushi
Jul 20 2017 05:44
is it compulsory to use or it's just optional?
Viktor Tiutiun
@vittorioVT
Jul 20 2017 05:44
@rushendrarushi just your condition was wrong
rushendra
@rushendrarushi
Jul 20 2017 05:45
wait le me correct my code
var myArray[]; for(i = 0; i <5; i++) { myArray.push(i); }
this is my cod
Viktor Tiutiun
@vittorioVT
Jul 20 2017 05:46
what is in instruction?
rushendra
@rushendrarushi
Jul 20 2017 05:47
i did it right i'm just asking is push is the only option we have or do we have any other options?
Viktor Tiutiun
@vittorioVT
Jul 20 2017 05:47
@rushendrarushi you need return myArray.push(i);
rushendra
@rushendrarushi
Jul 20 2017 05:48
ok so here myArray.push(i) is returning the i ? that's it?
Viktor Tiutiun
@vittorioVT
Jul 20 2017 05:48
@rushendrarushi there are other options :smile:
rushendra
@rushendrarushi
Jul 20 2017 05:48
@vittorioVT Thanks man..!!
CamperBot
@camperbot
Jul 20 2017 05:48
rushendrarushi sends brownie points to @vittoriovt :sparkles: :thumbsup: :sparkles:
:cookie: 793 | @vittoriovt |http://www.freecodecamp.com/vittoriovt
Viktor Tiutiun
@vittorioVT
Jul 20 2017 05:49
@rushendrarushi you're welcome
Addy
@addyleeliu
Jul 20 2017 06:17
hi, has anyone else run into the issue where in the Get Geolocation Data challenge under the JSON APIs and Ajax section, the text on the output phone doesn't change to your latitude and longitude when it's supposed to?
I clicked 'allow' when it asked to know my location and I passed the tests, but the text on the phone didn't change at all
Viktor Tiutiun
@vittorioVT
Jul 20 2017 06:28
@addyleeliu show your code
xiaoyimeng
@xiaoyimeng
Jul 20 2017 06:29
<style>
body { color: #000000;
}
</style>
what's wrong? thanks
sparlkle4000
@sparlkle4000
Jul 20 2017 06:30
Hello! I'm working on the Golf Code challenge. Can I essentially use any value for par?
Addy
@addyleeliu
Jul 20 2017 06:30

@vittorioVT
`<script>
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
$("#data").html("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);
});
}
</script>

<div id = "data">
<h4>You are here:</h4>

</div>`

Viktor Tiutiun
@vittorioVT
Jul 20 2017 06:31
@xiaoyimeng maybe background-color: #000;
xiaoyimeng
@xiaoyimeng
Jul 20 2017 06:31
thanks,I pass
Viktor Tiutiun
@vittorioVT
Jul 20 2017 06:32
@addyleeliu do you can in CodePen?
Addy
@addyleeliu
Jul 20 2017 06:32
``` 

<script>
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
$("#data").html("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);
});
}
</script>

<div id = "data">
<h4>You are here:</h4>

</div>

```

oops, I can't seem to format the code correctly
I just copy pasted the code they gave in the challenge instructions
Viktor Tiutiun
@vittorioVT
Jul 20 2017 06:35
@addyleeliu i see. this is challange. your code looks is correct
@addyleeliu try refresh your browser
Addy
@addyleeliu
Jul 20 2017 06:36
@vittorioVT are the latitude/longitude coordinates showing up for you?
Viktor Tiutiun
@vittorioVT
Jul 20 2017 06:38
@addyleeliu not, this is just challange
@addyleeliu are you trying to do this in your project?
__mifflin__
@cdrainxv
Jul 20 2017 06:42

@addyleeliu: It’s because you are using jQuery but haven’t imported it:

Settings ——> JS ——> Quickadd ——> jQuery

Also use the JS tab for javascript… no need to use script tags

$(document).ready(function() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(function(position) {
            $("#data").html(
                "latitude: " +
                    position.coords.latitude +
                    "<br>longitude: " +
                    position.coords.longitude
            );
        });
    }
});

in HTML tab:

<div>
  <h4 id="data"></h4>
</div>
Addy
@addyleeliu
Jul 20 2017 06:49
@vittorioVT i refreshed and nothing changed. I'm not trying to use this in any project, I
I'm just doing the challenges - this is the Get Geo-location Data one
@cdrainxv hmm I updated it but now it's not displaying anything at all
Viktor Tiutiun
@vittorioVT
Jul 20 2017 06:50
@addyleeliu your code is correct
Addy
@addyleeliu
Jul 20 2017 06:50
@vittorioVT do you know why it's not displaying the latitude/longitude data?
the code should be correct because I just copy pasted it from what the challenge prompt provided
@cdrainxv do I need to import jquery somewhere here?
https://www.freecodecamp.org/challenges/get-geolocation-data
Viktor Tiutiun
@vittorioVT
Jul 20 2017 06:53
@addyleeliu just add your code in your challenge. for me this works:
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
$("#data").html("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);
});
}
__mifflin__
@cdrainxv
Jul 20 2017 06:54
@addyleeliu: No… not for the fcc challenge… it’s already added in the background. Try the reset button and copy and paste it in again. Also make sure you select "Allow" when the prompt to search your location comes up.
Addy
@addyleeliu
Jul 20 2017 06:58
@vittorioVT @cdrainxv okay, I reset and copy pasted it in and clicked allow know location again but it's still not showing up
__mifflin__
@cdrainxv
Jul 20 2017 06:59
Then just move on…
Addy
@addyleeliu
Jul 20 2017 07:00
haha ok. thank you for your time and help! :)
__mifflin__
@cdrainxv
Jul 20 2017 07:00
Maybe quit and then relaunch your browser… or even try a differenct browser.
Addy
@addyleeliu
Jul 20 2017 07:01
i'll just worry about it again if i ever do a proj where i need to retrieve location data.
@cdrainxv @vittorioVT thank you!!
CamperBot
@camperbot
Jul 20 2017 07:01
addyleeliu sends brownie points to @cdrainxv and @vittoriovt :sparkles: :thumbsup: :sparkles:
:cookie: 794 | @vittoriovt |http://www.freecodecamp.com/vittoriovt
:star2: 2767 | @cdrainxv |http://www.freecodecamp.com/cdrainxv
Tejas B N
@tejasbanga
Jul 20 2017 07:11
I am right now doing the algorithm for truncating a string but I dont know how to cut a string if the word is not complete eg: if its Peter Piper, and he wants me to cut at 7 i am only able to return Peter P... instead of Peter... could anyone help me with this please?
Viktor Tiutiun
@vittorioVT
Jul 20 2017 07:18
@tejasbanga metods substr() or substring()
https://www.w3schools.com/js/js_string_methods.asp
Tejas B N
@tejasbanga
Jul 20 2017 07:27
@vittorioVT i got that but consider if the user passes something like "The sky is blue" and asks me to cut at 13 i should return "the sky is..." not "the sky is bl..." and that's my problem.
cykins4good
@cykins4good
Jul 20 2017 07:34
Hi to you all i need to to make the color of the text menu in my Navigation bar and the color of the text of full portfolio and my upcoming projects all to be gold color.I want the golden color to be static.How could i get this done. https://codepen.io/cykins4good/pen/weOqbd
cykins4good
@cykins4good
Jul 20 2017 07:41
@vittorioVT Hi to you all i need to to make the color of the text menu in my Navigation bar and the color of the text of full portfolio and my upcoming projects all to be gold color.I want the golden color to be static.How could i get this done
randomppl
@randomppl
Jul 20 2017 07:57
Hello my dear friends .

Below the main section, add a new section:

<div class="jumbotron">..</div>

Similar to what you added in the header section, add text for a heading, a paragraph, and a link that says Join.

Write CSS to style the link into a button and change the background image. Feel free to use your own image. Here's the image we used.

in hint it also saying like i need add h1 and p for what im not sure with same text Join
a href should be between div ?
John Gabriel Simmons
@sosmaniac-FCC
Jul 20 2017 08:13

Do you mean the following?

<h1>insert header</h1> ... <p>insert paragraph</p> ... <a href="#">linking text</a>

randomppl
@randomppl
Jul 20 2017 08:23
oh yes think so
<div class="jumbotron">

<h1>Join</h1>
<p>Join</p>
<a href="#">Join</a>
</div>
like this ?

In index.html, use the <h1> tag to add a heading, the <p> tag to add a paragraph, and the <a href="#"> tag to add a link. Give the link a class of btn.

Change the background image of .jumbotron by adding background: url( );. Insert the image URL between the parentheses.

i know how to add image
but what to do before ? I dont get it i have 3 words join on page now and it looks weird lol
They explain so bad
jeremydeshawn
@jeremydeshawn
Jul 20 2017 08:31
I have an ul that is aligned center but the bullets are not aligned vertically can someone tell me how to fix it.
May Kittens Devour Your Soul
@diomed
Jul 20 2017 08:44
I had something for this..
akashskycodder
@akashskycodder
Jul 20 2017 08:46
Change diplay property of ul element to display:block
May Kittens Devour Your Soul
@diomed
Jul 20 2017 08:47
ul {list-style-position: inside;}
@jeremydeshawn
cykins4good
@cykins4good
Jul 20 2017 08:55
Hi to you all i need to to make the color of the text menu in my Navigation bar and the color of the text of full portfolio and my upcoming projects all to be gold color.I want the golden color to be static.How could i get this done. https://codepen.io/cykins4good/pen/weOqbd
EpicTriffid
@EpicTriffid
Jul 20 2017 09:26

@EpicTriffid
Hi all. I'm working on my twitchAPI and i'm simplifying it myself first to just get it to console log each url I want to generate. Any idea where im going wrong with this?
var usernames = ["geekandsundry", "HardlyDifficult", "ESL_SC2", "OgamingSC2", "adobe", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb"]
var twitchAPI = "https://wind-bow.glitch.me/twitch-api/streams/";
var well = $(".well")

usernames.forEach(function () {
function genURL() {
for (var i = 0; i <= usernames.length; i++) {
twitchAPI + usernames[i]}
};
console.log(genURL)

wonder
@wonder2991
Jul 20 2017 09:28

@cykins4good

.navbar-inverse .navbar-nav>.active>a, .navbar-inverse .navbar-nav>.active>a:focus, .navbar-inverse .navbar-nav>.active>a:hover {
    color: gold;
    background-color: #080808;
}

for nav

kalikota ssv teja
@tejakali
Jul 20 2017 10:03

var Car = function() {
this.wheels = 4;
this.engines = 1;
this.seats = 5;
};

// Only change code below this line.

var myCar=new Car();
myCar.nickName= "twin";

property nickname should be string
showing error
??
wonder
@wonder2991
Jul 20 2017 10:09
try myCar.nickname= "twin";
kalikota ssv teja
@tejakali
Jul 20 2017 10:10
yeah tq
Stephen James
@sjames1958gm
Jul 20 2017 11:10
@EpicTriffid Did you figure out your log issue?
EpicTriffid
@EpicTriffid
Jul 20 2017 11:14
@sjames1958gm i did!
Stephen James
@sjames1958gm
Jul 20 2017 11:19
@EpicTriffid :+1:
just1witness
@just1witness
Jul 20 2017 12:19

@sjames1958gm Look I figured out the changing image problem I was having.

https://codepen.io/Just1witness/pen/BZRozr

Stephen James
@sjames1958gm
Jul 20 2017 12:20
@just1witness :+1: Great!
Look's good
just1witness
@just1witness
Jul 20 2017 12:21
@sjames1958gm thank you again for your help!
CamperBot
@camperbot
Jul 20 2017 12:21
just1witness sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8116 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 20 2017 12:21
@just1witness No problem, glad you got there
just1witness
@just1witness
Jul 20 2017 12:22
:)
Momozor
@momozor
Jul 20 2017 12:31
hello
Stephen James
@sjames1958gm
Jul 20 2017 12:32
@faraco :wave:
Momozor
@momozor
Jul 20 2017 12:32
:D
Orange
@summerbicycle
Jul 20 2017 12:38
can you help me find where is wrong
Stephen James
@sjames1958gm
Jul 20 2017 12:40
@summerbicycle Show your code.
Tejas B N
@tejasbanga
Jul 20 2017 12:41
@summerbicycle sure , get the code
cykins4good
@cykins4good
Jul 20 2017 12:50

Hi campers, how can i assign a to b with =
// Setup
var a;
var b = 2;

// Only change code below this line

a = 7; b = 7;

Stephen James
@sjames1958gm
Jul 20 2017 12:51
@cykins4good
You need a on the right of = instead of 7, for assigning a to b
Hello Everyone,
cykins4good
@cykins4good
Jul 20 2017 13:03
@sjames1958gm it seems not working
Stephen James
@sjames1958gm
Jul 20 2017 13:03
@cykins4good what do you have now, you might need to put on two lines for the test checker
I'm starting on my portfolio codepen, bumped into an issue where I can't line up my title and picture on the same line? I utilized col-xs-6 for my title and picture without it working.
Stephen James
@sjames1958gm
Jul 20 2017 13:03
@oatz :wave:
@sjames1958gm hi
Stephen James
@sjames1958gm
Jul 20 2017 13:04
@oatz Depending on your title element you might need to set the display property to inline
cykins4good
@cykins4good
Jul 20 2017 13:05

@sjames1958gm i came up with this // Setup
var a;
var b = 2;

// Only change code below this line

7; a = b

@sjames1958gm Ill try it
Stephen James
@sjames1958gm
Jul 20 2017 13:06
@cykins4good You removed your a = 7 which was correct.
And you are assign b to a not a to b
@cykins4good Assignment goes from right to left.
cykins4good
@cykins4good
Jul 20 2017 13:10
@sjames1958gm i corrected myself by doing this.But still not working.System still telling that a should be assigned to b with =
Stephen James
@sjames1958gm
Jul 20 2017 13:10
@cykins4good Should look like this
a = 7;
b = a;
cykins4good
@cykins4good
Jul 20 2017 13:10
@sjames1958gm ok let me try
@sjames1958gm ok, maybe im doing it wrong. Where do i place the "span" tags with respect to the "div" tags, "h1", and "a"?
<div="row">
<div class="col-xs-6">
<h1> </h1>
</div>
<div class="col-xs-6">
<a href="
"> <img class="img-responsive" src="__"/></a>
</div>
</div>
Stephen James
@sjames1958gm
Jul 20 2017 13:13
@oatz All depends on what you want it to look like? Are you using span to get display inline?
You will probably need to use css display: inline on the h1 and a tags.
Jake
@JakeDVirus
Jul 20 2017 13:15
anyone just check out the javascript code in my pen and check out the line19 where i wrote the statement if(document.readyState === "complete").
Is that statement redundant in that position and i shall move that statement to somewhere else or is it ok in that position?
i ll highly appreciate this favour.
https://codepen.io/neel111/pen/dRBQNY
Stephen James
@sjames1958gm
Jul 20 2017 13:17
@NeelDVirus You will probably need to wait for document ready to assign this event listener
document.getElementsByClassName("buttonQ")[0].addEventListener("click", makeRequest);
But if you can respond to a button click then the document is already ready and that check is redundant.
Manish Giri
@Manish-Giri
Jul 20 2017 13:25
@diomed :wave:
Jake
@JakeDVirus
Jul 20 2017 13:26
@sjames1958gm oh yeah thanks i get your point. so where should i put that statement if the context was something different (like the button click was not there). should i nest the whole code inside the statement if(document.readyState === "complete")
CamperBot
@camperbot
Jul 20 2017 13:26
neeldvirus sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8118 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
cykins4good
@cykins4good
Jul 20 2017 13:27
@sjames1958gm Thanks a lot. i appreciate your assistance
@sjames1958gm I'm still not getting an inline display of my h1 and a tags.
Stephen James
@sjames1958gm
Jul 20 2017 13:28
@NeelDVirus The problem with that check is you only check once. I found this alternative
var callback = function(){
  // Handler when the DOM is fully loaded
};

if (document.readyState === "complete" ||
    (document.readyState !== "loading" && !document.documentElement.doScroll))  {
  callback();
} else {
  document.addEventListener("DOMContentLoaded", callback);
}
Maybe I should rephrase my question: The preview of how the page looks, is it different when I scale the page view narrower or wider? Because the image (in "a" tag) scales but not my h1 tag.
Stephen James
@sjames1958gm
Jul 20 2017 13:30
doScroll might be for older IE browsers. "onload" handler would work, but it waits for images to load as well
Jake
@JakeDVirus
Jul 20 2017 13:30
@sjames1958gm is the doScroll needed for IE8. if not then i can skip that i guess
Stephen James
@sjames1958gm
Jul 20 2017 13:31
@oatz I don't believe the h1 tag will scale, not even sure how to do that. The image scales because of img-responsive
@NeelDVirus Yeah I think so, probably not needed
Jake
@JakeDVirus
Jul 20 2017 13:33
@sjames1958gm if the conditiondocument.readyState === "complete" is already given then what is the logical need of adding document.readyState !== loading along with the previous condition in the if statement?
郝日文
@haoriwen
Jul 20 2017 13:36
你的p元素必须包含Monkey code。
怎么弄了
Stephen James
@sjames1958gm
Jul 20 2017 13:37
@NeelDVirus I am not exactly sure. The idea is to only register for the DOMContentLoaded event if it hasn't yet fired.
Unless you have a specific need - "onload" event is sufficient for now. "complete" seems to be the state right before onload is fired
EpicTriffid
@EpicTriffid
Jul 20 2017 13:42
@EpicTriffid
why arent my buttons working?
https://codepen.io/EpicTriffid/pen/rwEmgQ?editors=0001
Manish Giri
@Manish-Giri
Jul 20 2017 13:45
@EpicTriffid look at the browser console
not the codepen one
EpicTriffid
@EpicTriffid
Jul 20 2017 13:50
right, its trying to load data for null fields thats arent there?
Manish Giri
@Manish-Giri
Jul 20 2017 13:57
yes
sarthakcoder
@sarthakcoder
Jul 20 2017 14:02
Jake
@JakeDVirus
Jul 20 2017 14:07

@sjames1958gm i modified the code a bit to use the condition document.readyState === "complete". but the click event is not working now
given below is the modified code

(function(){
    var httpR;
    function makeRequest(){
    function reqListener() {
      if(httpR.readyState === XMLHttpRequest.DONE) {
        var quote;
        if(httpR.status === 200) {
          quote = JSON.parse(httpR.responseText);
          document.getElementsByClassName("quote")[0].innerHTML = quote[0].body;
        } else {
          alert("There was a problem with the request!")
        }
      }
    }
    httpR = new XMLHttpRequest();
    httpR.onreadystatechange = reqListener
    httpR.open("GET", "https://quote-api.glitch.me/pull/1", true);
    httpR.send();
  }
    window.addEventListener("load", makeRequest);

    if(window.readyState === "complete") {
        document.getElementByClassName("buttonQ")[0].addEventListener("click", makeRequest);
    } else {
        document.getElementsByClassName("buttonQ")[0].addEventListener("DOMContentLoaded", makeRequest);
    }
})();

given below is the unmodified previous code which worked

(function(){
  var httpR;
  window.addEventListener("load", makeRequest);
  //window.onload = makeRequest;
  document.getElementsByClassName("buttonQ")[0].addEventListener("click", makeRequest);

  function makeRequest(){
    function reqListener() {
      if(httpR.readyState === XMLHttpRequest.DONE) {
        var quote;
        if(httpR.status === 200) {
          quote = JSON.parse(httpR.responseText);
          document.getElementsByClassName("quote")[0].innerHTML = quote[0].body;
        } else {
          alert("There was a problem with the request!")
        }
      }
    }
    httpR = new XMLHttpRequest();
    httpR.onreadystatechange = reqListener
    httpR.open("GET", "https://quote-api.glitch.me/pull/1", true);
    httpR.send();
  }
})();

where is the bug in the modified code?

madhuri soni
@sonimadhuri
Jul 20 2017 14:09
@sarthakcoder paste your code here
levani452000
@levani452000
Jul 20 2017 14:22
heeelp how i can center contact and page 3 buttons in this navigation bar??
i min center verticaly
mean
Stephen James
@sjames1958gm
Jul 20 2017 14:44

@NeelDVirus I would do the following - register the click handler in the "load" handler, if you want to make the request on load

window.addEventListener("load", function(event) {
    document.getElementByClassName("buttonQ")[0].addEventListener("click", makeRequest);
    makeRequest();
});

Dispense with the if check

@sarthakcoder Show your code here
Darren
@DarrenfJ
Jul 20 2017 15:00
morning fCC
hay buddy! :wave: @sjames1958gm
Stephen James
@sjames1958gm
Jul 20 2017 15:00
@DarrenfJ :wave:
Darren
@DarrenfJ
Jul 20 2017 15:08
a big ty to Manish for the help with my Q earleir in pm.. thanks @Manish-Giri
CamperBot
@camperbot
Jul 20 2017 15:08
darrenfj sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6286 | @manish-giri |http://www.freecodecamp.com/manish-giri
Darren
@DarrenfJ
Jul 20 2017 15:08
saved me hours of digging for info and way faster than the forums ;)
John Tendik
@JohnTendik
Jul 20 2017 15:14
damn manish with 6k points
almost past @rphares
Darren
@DarrenfJ
Jul 20 2017 15:15
Manish has been a monster in the helprooms ;)
but @sjames1958gm 's been rawking it too..
about @sjames1958gm
CamperBot
@camperbot
Jul 20 2017 15:16
:star2: 8119 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
John Tendik
@JohnTendik
Jul 20 2017 15:16
damn
eh
Darren
@DarrenfJ
Jul 20 2017 15:16
literally... a gazillion brownies ;)
John Tendik
@JohnTendik
Jul 20 2017 15:16
good man
its nice that they enjoy helping people
Darren
@DarrenfJ
Jul 20 2017 15:17
it's always muchly appreciated...
knight2
@knight2
Jul 20 2017 15:18

I am on FCC React tutorial.

They want us to use arrow functions to automatically bind this to the function, instead of having to do that in the constructor.

I need to include transform-class-properties from babel.

In CodePen, they have us add links to the external libraries.

Here is the extension on github
https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-class-properties

But I can't tell what link I should add to my javascript options on codepen. Any suggestions?

John Tendik
@JohnTendik
Jul 20 2017 15:20
you can try this
Darren
@DarrenfJ
Jul 20 2017 15:20
@knight2 Do you know if it's shared on any CDN anywhere?
John Tendik
@JohnTendik
Jul 20 2017 15:20
nvm
bad link
lol
Darren
@DarrenfJ
Jul 20 2017 15:21
ah @JohnTendik 's got you covered...
John Tendik
@JohnTendik
Jul 20 2017 15:21
`
https://unpkg.co/babel-plugin-transform-class-properties@6.24.1
Darren
@DarrenfJ
Jul 20 2017 15:21
thanks @JohnTendik
CamperBot
@camperbot
Jul 20 2017 15:21
darrenfj sends brownie points to @johntendik :sparkles: :thumbsup: :sparkles:
:cookie: 791 | @johntendik |http://www.freecodecamp.com/johntendik
Darren
@DarrenfJ
Jul 20 2017 15:21
also, Ontario? Where you located brutha?
John Tendik
@JohnTendik
Jul 20 2017 15:21
Really close to Toronto :)
Darren
@DarrenfJ
Jul 20 2017 15:21
ah cool
John Tendik
@JohnTendik
Jul 20 2017 15:21
Kitchener waterloo
Darren
@DarrenfJ
Jul 20 2017 15:22
the tri cities!
noice
John Tendik
@JohnTendik
Jul 20 2017 15:22
yaya
knight2
@knight2
Jul 20 2017 15:22
@JohnTendik thanks! How did you find that link btw?
CamperBot
@camperbot
Jul 20 2017 15:22
knight2 sends brownie points to @johntendik :sparkles: :thumbsup: :sparkles:
:cookie: 792 | @johntendik |http://www.freecodecamp.com/johntendik
John Tendik
@JohnTendik
Jul 20 2017 15:22
@knight2 i googled babel-plugin-transform-class-properties cdn
cdn is content delivery network
Darren
@DarrenfJ
Jul 20 2017 15:23
the power of greyskull
John Tendik
@JohnTendik
Jul 20 2017 15:23
they will normally host popular scripts and packages for easy access
:D
knight2
@knight2
Jul 20 2017 15:23
ahh yeah I googled babel-plugin-transform-class-properties but without cdn
Darren
@DarrenfJ
Jul 20 2017 15:23
the power of greyskull google
John Tendik
@JohnTendik
Jul 20 2017 15:23
xD gatta be more specific
knight2
@knight2
Jul 20 2017 15:24
Strange, even with it included in the external javascript (not sure if I should, no .js ending in the link), CodePen still says it unexpcted token in the arrow function
(I pass the challenge on the FCC in browser website just fine, but they don't really give you much info for setting it up on codepen/externally )
John Tendik
@JohnTendik
Jul 20 2017 15:25
you can always copy paste the contents inside the file into codepen before your scripts at the top
maybe that will work?
hmmm just tried it didnt work
Sweet Coding :)
@SweetCodingInc
Jul 20 2017 15:27
@knight2 When using class representation, functionName = () => {} becomes invalid expression
it should be functionName() {}
knight2
@knight2
Jul 20 2017 15:27
Which is why you include the library right?
Sweet Coding :)
@SweetCodingInc
Jul 20 2017 15:28
Nope.
class expects you to have functionName(){} pattern as first level children
otherwise that's a syntax error
knight2
@knight2
Jul 20 2017 15:28
Okay the code runs now in CodePen but the function doesn't update now
Sweet Coding :)
@SweetCodingInc
Jul 20 2017 15:32
@knight2 in you constructor, you need to add this.setMessage = this.setMessage.bind(this);
otherwise this inside setMessage becomes undefined
knight2
@knight2
Jul 20 2017 15:32
I think you are missing the point
Intro: There is another way to bind this when writing methods in React component classes. A useful, concise way is to use an ES6 arrow function. It does not assign its own value for this, but instead adopts the value of this fhttps://gitter.im/FreeCodeCamp/Help/~chat#markdownrom the context surrounding the function when it is written. In other words, an arrow function binds this automatically from its surrounding context. 
The use of an arrow function as a class property like this is technically still an experimental feature of JavaScript (ES7 property initializers) but can be enabled through pre-processing. It's very useful because of its conciseness, but keep in mind that it is not part of the official language yet. Using this syntax means you can define a class method as an arrow function and not have to explicitly bind this in the constructor.Instructions: Initialize the state of MyComponent so there is a message key with a value of Hello!. The component renders a button that, when clicked, triggers a setMessage() method. Define this method with an ES6 arrow function. It should change the state of message to Goodbye!. Note that to pass the tests the arrow function must be written without any arguments.

http://hysterical-amusement.surge.sh/ React section 26. Using function(){} syntax does not work.

The only way for it to work is yes, to bind it directly, or use ES6 arrow functions

I could just bind every single function I use, but it seems like they are encouraging use of arrow functions through Babel transform and ES6, and this might be an issue when I later try to do projects and can't get the right libraries to run the code that FCC wants me to use
Sydney
@SydneyWarren
Jul 20 2017 15:37

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  if (source.hasOwnProperty('last') === true) {
  var search = source.last;
  console.log(collection[0].last);
  for (var i = 0; i < collection.last.length; i++) {

  }
  }
  // Only change code above this line
  return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
why can't i iterate throught collection.last.length?
knight2
@knight2
Jul 20 2017 15:38
You aren't iterating throug the collection properly
And you are checking source instead of collection
You need the grab the keys from source, then you need to iterate through the collection, or use one of those new methods you learned in that section (map/filter/etc), then check for the condition you are looking for
@SydneyWarren Once you change what I said above, you'll want to go through each item in the collection, and return the item only if the property (aka first/last/whatever) matches the source property, and that the key for that property also matches the key property.
Sydney
@SydneyWarren
Jul 20 2017 15:44
@knight2 thanks
CamperBot
@camperbot
Jul 20 2017 15:44
sydneywarren sends brownie points to @knight2 :sparkles: :thumbsup: :sparkles:
:cookie: 122 | @knight2 |http://www.freecodecamp.com/knight2
Sweet Coding :)
@SweetCodingInc
Jul 20 2017 15:45
@knight2 I got your point... For babel-plugin-transform-class-properties to work as you intend to, you need this config in .babelrc
{
  "plugins": ["transform-class-properties"]
}
not sure, how that can be done in codepen
knight2
@knight2
Jul 20 2017 15:46

@SweetCodingInc Didn't mean to come off mean, it is just frustrating when you know the code but your errors are all with the configuration of the libraries.

How would I config that in .babelrc on CodePen?

Sweet Coding :)
@SweetCodingInc
Jul 20 2017 15:46
@knight2 no worries...
I have no idea how to configure .babelrc on codepen
Kyle Holm
@thekholm80
Jul 20 2017 15:46
i'd suggest developing locally if you wish to use React
knight2
@knight2
Jul 20 2017 15:47

I've been having problems as well configuring all the libraries for sass/react/etc on the beta course. I guess for now i'll just use the in browser editor, then spend time trying to configure a local setup once I finish everything before I start doing the project challenges.

@thekholm80 @SweetCodingInc @JohnTendik @DarrenfJ thanks though!

CamperBot
@camperbot
Jul 20 2017 15:48
knight2 sends brownie points to @thekholm80 and @sweetcodinginc and @johntendik and @darrenfj :sparkles: :thumbsup: :sparkles:
:cookie: 138 | @sweetcodinginc |http://www.freecodecamp.com/sweetcodinginc
:warning: knight2 already gave johntendik points
:star2: 1350 | @thekholm80 |http://www.freecodecamp.com/thekholm80
:star2: 1920 | @darrenfj |http://www.freecodecamp.com/darrenfj
Darren
@DarrenfJ
Jul 20 2017 15:48
ooOooo this might be a time to try it in Glitch.... @knight2
Kyle Holm
@thekholm80
Jul 20 2017 15:49
I've put my SPAs on firebase, it's pretty handy
Darren
@DarrenfJ
Jul 20 2017 15:49
I think fCC wants to move away from CodePen.. haven't used gitch to know enough what you can do in the backend.. but I keep hearing good things
Kyle Holm
@thekholm80
Jul 20 2017 15:49
I wonder if you can use Glitch without building a back end?
I'm pretty sure Heroku requires you to build a back end
Darren
@DarrenfJ
Jul 20 2017 15:50
was trying to use SemanticUi for my portfolio project and similarly there's just so muhc more you can do ewith it locally.. so I abandonned it and went back to Bootstrap :/
I got the impression it was like Cloud9 in terms of you say blah blah and it set's up the environment for you.. although like i said i didn't really use it.. I think it was when I was checking out the API stuff in the beta curriculum
Kyle Holm
@thekholm80
Jul 20 2017 15:52
i looked at Glitch a little when Heroku asked for my credit card but I didn't like their workflow
knight2
@knight2
Jul 20 2017 15:52
@DarrenfJ glitch looks interesting. I think I need to just forget about it for now, and just use the in browser lesson editor to power through these tutorials. Literally every lesson for the front end libs in the beta course I have had issues using libraries outside of the in browser editor. --- Also a lot of the libraries FCC uses are no where close to the latest stable builds, nor do they really take into consideration that people will be using CodePen or sublimetext/atom/visual studio code (even though there is plenty of documentation on how to use libraries, FCC might want to take a better initiative on that... )
Winston
@Xeptic
Jul 20 2017 15:53
Any idea in python how to edit another modules class variables without sending "self"
this shit got me stumped for hours
Darren
@DarrenfJ
Jul 20 2017 15:53
I hear yah brutha.. I think they're saddled with the inevitabilities of relying on vast numbers of volunteers... (aka always being behind and having too much to get done)
anyhoooooooo i gotta run and focus on testing
Kyle Holm
@thekholm80
Jul 20 2017 15:54
@DarrenfJ :wave:
Darren
@DarrenfJ
Jul 20 2017 15:54
so thanks yous and kudos to everyone helping out in the helpRooom... for all the brownies you missed out on...
thanks @thekholm80 @knight2 @SweetCodingInc @JohnTendik @sjames1958gm
CamperBot
@camperbot
Jul 20 2017 15:54
darrenfj sends brownie points to @thekholm80 and @knight2 and @sweetcodinginc and @johntendik and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 123 | @knight2 |http://www.freecodecamp.com/knight2
:cookie: 139 | @sweetcodinginc |http://www.freecodecamp.com/sweetcodinginc
:warning: darrenfj already gave johntendik points
:star2: 1351 | @thekholm80 |http://www.freecodecamp.com/thekholm80
:star2: 8121 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Darren
@DarrenfJ
Jul 20 2017 15:55
later teammates ;)
Kyle Holm
@thekholm80
Jul 20 2017 15:55
@DarrenfJ thanks!
CamperBot
@camperbot
Jul 20 2017 15:55
thekholm80 sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 1921 | @darrenfj |http://www.freecodecamp.com/darrenfj
Sweet Coding :)
@SweetCodingInc
Jul 20 2017 15:56
@DarrenfJ Thanks :)
CamperBot
@camperbot
Jul 20 2017 15:56
sweetcodinginc sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 1922 | @darrenfj |http://www.freecodecamp.com/darrenfj
Winder
@Windersz
Jul 20 2017 16:04
求问如何给p元素添加red-text类啊
有点搞不懂
cykins4good
@cykins4good
Jul 20 2017 16:04
Hi to you all.PLease i need to know when i will be eligible to claim my front-end certification since i have completed my Basic Front-end projects and i have submitted them.
Winder
@Windersz
Jul 20 2017 16:04
这里都是基本上不教理论直接实战
在做的时候总感觉自己就是一只一知半解的鸭子
if you've done all the required work you should be able to claim it right away
Boby Y.
@Boobsled
Jul 20 2017 16:10
///
///
Goddamit how do I copy code again
Kyle Holm
@thekholm80
Jul 20 2017 16:11
ctrl c to copy
Boby Y.
@Boobsled
Jul 20 2017 16:11
 if (golfscore(1,1)){return "Hole-in-one!";}
  else if (stroke<=(par-2)){return "Eagle";}
  else if((stroke = par-1)){ return "Birdie";}
  else if(stroke=par){return "Par";}
  else if(stroke=(par+1)){return "Bogey";}
can someone tell me why this is wrong please?
Joseph
@revisualize
Jul 20 2017 16:12

If you are posting code that is large, Please use Gist - https://gist.github.com/ then please paste the link here.
...
How to do code block format: ..... PLEASE try with a small block of code before you try to make a bigger one.
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code
```js [SHIFT+ENTER]
// your code here
``` [CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

...
You can also do inline code formatting:
A string of text with a `variable` or `other bit of code`.
Output:
A string of text with a variable or other bit of code.

@Boobsled Your if condition isn't correct.
Boby Y.
@Boobsled
Jul 20 2017 16:13
@thekholm80 stroke = par and stroke=par+1 says that itw as expecting a function but got an expression
Joseph
@revisualize
Jul 20 2017 16:13
@Boobsled In golf how many strokes for a Hole in one?
1
Boby Y.
@Boobsled
Jul 20 2017 16:13
@revisualize correct... I only have a problem with the last two
Joseph
@revisualize
Jul 20 2017 16:13
@Boobsled Everything for that challenge should be compared to strokes
Kyle Holm
@thekholm80
Jul 20 2017 16:14
@Boobsled stroke = par means you're assigning the value of par to stroke. === compares values
Joseph
@revisualize
Jul 20 2017 16:14
= is assignment
Boby Y.
@Boobsled
Jul 20 2017 16:14
OOOH @thekholm80
YOURE RIGHT
Joseph
@revisualize
Jul 20 2017 16:14
@Boobsled Your first condition is still incorrect.
Boby Y.
@Boobsled
Jul 20 2017 16:16
@revisualize should I just say if golfscore(1,par){return "Hole-in_one";}?
that would be correct right?
cykins4good
@cykins4good
Jul 20 2017 16:17
@thekholm80 Thanks a lot.
Kyle Holm
@thekholm80
Jul 20 2017 16:18
@cykins4good did you get it?
cykins4good
@cykins4good
Jul 20 2017 16:21
@thekholm80 Yes i did got the link.I am still a long way to getting the Cert.But how will get my real name to be printed on it as i have my email address as my username.
Winston
@Xeptic
Jul 20 2017 16:22
look guys, i'm willing to get on my knees and do what needs to be done for an answer here...
I'm trying to send a variable to another class and append it to a list, problem is that class function has "self" and keeps giving me an error "1 arguement given 2 expected"
but if I send "self" along with that variable it's telling me the class I sent it from doesn't have the list I'm trying to append to
which duuurrr obviously, the list is in the class I'm trying to send it it
to*
oh, python.. I feel I should have mentioned that sooner
Kyle Holm
@thekholm80
Jul 20 2017 16:25
@cykins4good I'm not sure about that, sorry. You might check the forums
@Xeptic i'm not sure there's a lot of python folks here
Winston
@Xeptic
Jul 20 2017 16:26
:'(
Kyle Holm
@thekholm80
Jul 20 2017 16:26
Winston
@Xeptic
Jul 20 2017 16:27
sweet ty
May Kittens Devour Your Soul
@diomed
Jul 20 2017 16:28
just use that stackoverflow answer extractor for python
hi @thekholm80 :cat:
how's the FCC against Humanity project going?
Chompy against Humanity :yum:
cykins4good
@cykins4good
Jul 20 2017 16:31
I am not yet ripe for python. I mean how to getting my real name on my Github profile so as to reflect on my Front-end development cert.
May Kittens Devour Your Soul
@diomed
Jul 20 2017 16:34
@cykins4good he wasn't talking to you anyway
go to Github settings and change your name there
Kyle Holm
@thekholm80
Jul 20 2017 16:41
@diomed haven't touched it in about a week. I'm going to finish the FCC project i'm working on then i'll do a bit more
May Kittens Devour Your Soul
@diomed
Jul 20 2017 16:42
oaky
Shashank
@superheroslife
Jul 20 2017 16:48
hello guys
@bestintown23 shitty work nigger
Pieter Stokkink
@forkerino
Jul 20 2017 16:53
Please censor yourself
May Kittens Devour Your Soul
@diomed
Jul 20 2017 16:54
oh, it's that time again...
Chris
@bestintown23
Jul 20 2017 16:55
@superheroslife excuse me??????????????????????????????????
dont get killed and yes that is a threat boy @superheroslife
back to our normal scheduled programming
May Kittens Devour Your Soul
@diomed
Jul 20 2017 16:59
.
Momozor
@momozor
Jul 20 2017 17:00
@superheroslife is simply a troll.
CamperBot
@camperbot
Jul 20 2017 17:00
:trollface: troll problems? notify admins here
Lance
@texas2010
Jul 20 2017 17:01
move on. he got banned.
Chris
@bestintown23
Jul 20 2017 17:04
@texas2010 move on. he got banned? you don't sound too compassionate about the matter.
Jake
@JakeDVirus
Jul 20 2017 17:04
@sjames1958gm yeah that is efficient
Lance
@texas2010
Jul 20 2017 17:05
i dont meant that way. i just want to let them know about he got banned.
John Tendik
@JohnTendik
Jul 20 2017 17:06
more drama
oh boi
wat i miss
Lance
@texas2010
Jul 20 2017 17:06
then i am sorry. i trying to be polite.
Sydney
@SydneyWarren
Jul 20 2017 17:08

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var searchFor = Object.keys(source);
  collection.filter(searchFor);
  // Only change code above this line
  return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
why wont the filter method work?
Momozor
@momozor
Jul 20 2017 17:08
because you are spelling it as fliter
Chris
@bestintown23
Jul 20 2017 17:09
@texas2010 well thank you.
CamperBot
@camperbot
Jul 20 2017 17:09
bestintown23 sends brownie points to @texas2010 :sparkles: :thumbsup: :sparkles:
:star2: 1279 | @texas2010 |http://www.freecodecamp.com/texas2010
Sydney
@SydneyWarren
Jul 20 2017 17:09
still doesn't work @faraco even after i changed it
May Kittens Devour Your Soul
@diomed
Jul 20 2017 17:09
@texas2010 is not the one who is compassionate.
He is the 1 who BANS :smiling_imp:
Stephen James
@sjames1958gm
Jul 20 2017 17:10
@SydneyWarren filter expects a function not an array
Lance
@texas2010
Jul 20 2017 17:11
i do care. i feel he disrespect to you. that is why he got banned. and violated code of conduct.
John Tendik
@JohnTendik
Jul 20 2017 17:11
@SydneyWarren filter accepts a function does it not ?
Chris
@bestintown23
Jul 20 2017 17:11
@diomed im just saying it doesnt hurt to be compassionate especially about something that is not a joking manner.
John Tendik
@JohnTendik
Jul 20 2017 17:11
filter params:
` callback Function is a predicate, to test each element of the array. Return true to keep the element, false otherwise, taking three arguments: ~
May Kittens Devour Your Soul
@diomed
Jul 20 2017 17:12
@bestintown23 he practically killed the guy for you,what more do you want? :smile:
Chris
@bestintown23
Jul 20 2017 17:12
@diomed for you not to smile at all about this situation.
May Kittens Devour Your Soul
@diomed
Jul 20 2017 17:13
:sob:
Chris
@bestintown23
Jul 20 2017 17:13
im going back to coding now.
Sydney
@SydneyWarren
Jul 20 2017 17:14

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var searchFor = Object.keys(source);
 var request = collection.filter(function(word) {
    return source;
  });
  console.log(request);
  // Only change code above this line
  return arr;
}
Alexander Køpke
@alexanderkopke
Jul 20 2017 17:14
who got banned?
Sydney
@SydneyWarren
Jul 20 2017 17:14
still isn't working, am i going the right away about this function?
is it possible to iterate through objects how you do through an array? this challenge is so confusing
Momozor
@momozor
Jul 20 2017 17:15
@SydneyWarren I think you should see this before going any further.
Sydney
@SydneyWarren
Jul 20 2017 17:16
i've read that
i just dont understand it
i thought thats what i was doing there ^
John Tendik
@JohnTendik
Jul 20 2017 17:17
so youre close, but youre not using Object.keys correctly
// array like object with random key ordering
var anObj = { 100: 'a', 2: 'b', 7: 'c' };
console.log(Object.keys(anObj)); // ['2', '7', '100']
object.keys will return an array of the keys for an objecty
so for you searchFor becomes [] inside the array whatever the source is, im guessing its actually a string to search the object
Sydney
@SydneyWarren
Jul 20 2017 17:19
is that what object.keys does turn objects into an array?
i cheated though i got so frustrated and looked at the answerss
John Tendik
@JohnTendik
Jul 20 2017 17:19
it will turn the keys inside an array/object into a new array with just the keys
Sydney
@SydneyWarren
Jul 20 2017 17:19
@JohnTendik why would anyone want that it doesn't have the value of the keys
John Tendik
@JohnTendik
Jul 20 2017 17:20
{myKey:1,twoKey:2} == ["myKey","twoKey"]
what is the contents of source variable
is it an array or just a string?
Sydney
@SydneyWarren
Jul 20 2017 17:20
slow down your confusing me
so when you do the keys thing
why just have the key if it doesn't come with the value
John Tendik
@JohnTendik
Jul 20 2017 17:21
because sometimes you need the key specifically to access the value
Corentin Whyte
@CorySW
Jul 20 2017 17:22
I would like to generate a random sequence of numbers between 1-4 how could I do it ?
Sydney
@SydneyWarren
Jul 20 2017 17:22
ok so for this test now we have the keys... is the next step run those through the collection?
John Tendik
@JohnTendik
Jul 20 2017 17:23
im not sure what challenge youre on
but that sounds about right
ooh ok i see it now
hmm nvm that wont work
Stephen James
@sjames1958gm
Jul 20 2017 17:30
@CorySW This is a function that will give you random from min to max, call with (1,4)
function randomRange(min, max) {
  return Math.floor(Math.random() * (max - min + 1) + min);
}
John Tendik
@JohnTendik
Jul 20 2017 17:30
@SydneyWarren
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var searchFor = Object.keys(source);
  var request = collection.filter(function(word) {
    for(var searchTerm in searchFor){
        return word[searchFor[searchTerm]] === source[searchFor[searchTerm]];
    }
  });
  console.log(request);
  // Only change code above this line
  return arr;
}
try that
Stephen James
@sjames1958gm
Jul 20 2017 17:32
@JohnTendik @SydneyWarren
That won't work, you need to verify that all the keys in searchFor array match, not just one
Also you should probaly return the filter result at the bottom
John Tendik
@JohnTendik
Jul 20 2017 17:33
ye well again i dont know what her challenge is, im working off her original post
Stephen James
@sjames1958gm
Jul 20 2017 17:36
@SydneyWarren What you need inside the filter function is
return true if for every key from source, word has that key and it matches the value in source.
Chris
@bestintown23
Jul 20 2017 18:01
how can i move the social media icons to be on the right side of the page and display in a row along with my h1 element? https://codepen.io/bestintown23/pen/MoNEMQ
catapulto
@catapulto
Jul 20 2017 18:05
hey please tell me that recursion is only way to build a factorial program or not???
cause i trying to do it with for loop and doesnot why its not working?
help appreciated.
Stephen James
@sjames1958gm
Jul 20 2017 18:08
@catapulto Recursion is not the only way. Any recursive program can be written without.
@catapulto Show your non-recursive "solution"
Joseph
@revisualize
Jul 20 2017 18:12
Hey.
catapulto
@catapulto
Jul 20 2017 18:12

function factorialize(num) {
for (var i=1;i>=num;i++){
num*=i;
}
return num;
}

factorialize(5);

@sjames1958gm
Manish Giri
@Manish-Giri
Jul 20 2017 18:12
@catapulto i >= num
is this right?
you're starting from i(=1), and you want to go up to num
Stephen James
@sjames1958gm
Jul 20 2017 18:12
@catapulto You cannot use num both as your factorial and your test variable.
May Kittens Devour Your Soul
@diomed
Jul 20 2017 18:13
hi @Manish-Giri :cat:
catapulto
@catapulto
Jul 20 2017 18:13
but the args is 5
Stephen James
@sjames1958gm
Jul 20 2017 18:13
function factorialize(num) {
var f = 1
for (var i=2;i<=num;i++){
f*=i;
}
return f;
}
Manish Giri
@Manish-Giri
Jul 20 2017 18:13
@sjames1958gm :wave:
catapulto
@catapulto
Jul 20 2017 18:13
okay
Stephen James
@sjames1958gm
Jul 20 2017 18:13
@Manish-Giri Yo
catapulto
@catapulto
Jul 20 2017 18:13
@sjames1958gm thanks
CamperBot
@camperbot
Jul 20 2017 18:13
catapulto sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8122 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 20 2017 18:14
@catapulto If you use num as the factorial number the loop will go forever as i chases the ever increasing num
Manish Giri
@Manish-Giri
Jul 20 2017 18:14
@diomed :wave:
catapulto
@catapulto
Jul 20 2017 18:14
but one question why test variable has to be different? @sjames1958gm
Stephen James
@sjames1958gm
Jul 20 2017 18:14
@catapulto If you use num as the factorial number the loop will go forever as i chases the ever increasing num
catapulto
@catapulto
Jul 20 2017 18:15
how? @sjames1958gm i cant get it.
just1witness
@just1witness
Jul 20 2017 18:15
Can someone please open this and confirm that it gives you your local weather. Someone who doesn't live in NY. :)
Stephen James
@sjames1958gm
Jul 20 2017 18:15
for (var i=2;i<=num;i++){ num*=i; }
as i goes from 2, 3, 4, 5, 6
num is 10, 30, 120, 600, 3600
so i can never catch num
catapulto
@catapulto
Jul 20 2017 18:15
sorry for frustating you @sjames1958gm
Can someone please open this and confirm that it gives you your local weather. Someone who doesn't live in NY. :)
Manish Giri
@Manish-Giri
Jul 20 2017 18:15
@just1witness works for me
just1witness
@just1witness
Jul 20 2017 18:16
Ahh!!!!!!!!! I'm so happy right now.
May Kittens Devour Your Soul
@diomed
Jul 20 2017 18:16
@just1witness it's good 4 me too, and I usually can't open it :smile:
Stephen James
@sjames1958gm
Jul 20 2017 18:16
@catapulto
for (var i=2;i<=num;i++){ num*=i; }
as i goes from 2, 3, 4, 5, 6
num is 10, 30, 120, 600, 3600
so i can never catch num
just1witness
@just1witness
Jul 20 2017 18:16
@Manish-Giri Thank you!
CamperBot
@camperbot
Jul 20 2017 18:16
just1witness sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6287 | @manish-giri |http://www.freecodecamp.com/manish-giri
just1witness
@just1witness
Jul 20 2017 18:16
@diomed Thank you!
CamperBot
@camperbot
Jul 20 2017 18:16
just1witness sends brownie points to @diomed :sparkles: :thumbsup: :sparkles:
:star2: 5178 | @diomed |http://www.freecodecamp.com/diomed
Stephen James
@sjames1958gm
Jul 20 2017 18:16
@just1witness :+1: works here - 99 degrees out
just1witness
@just1witness
Jul 20 2017 18:16
@ahmedtarek2134 Thank you!
CamperBot
@camperbot
Jul 20 2017 18:16
:cookie: 578 | @ahmedtarek2134 |http://www.freecodecamp.com/ahmedtarek2134
just1witness sends brownie points to @ahmedtarek2134 :sparkles: :thumbsup: :sparkles:
Ahmed Tarek
@ahmedtarek2134
Jul 20 2017 18:17
@diomed cougghhh
just1witness
@just1witness
Jul 20 2017 18:17
@sjames1958gm Thank you!
CamperBot
@camperbot
Jul 20 2017 18:17
just1witness sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8123 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 20 2017 18:17
@catapulto Not frustrated, glad you have a inquiring mind
May Kittens Devour Your Soul
@diomed
Jul 20 2017 18:20
@ahmedtarek2134 do u have a bronhitis? :yum:
Ahmed Tarek
@ahmedtarek2134
Jul 20 2017 18:21
waaaaaa
Joseph
@revisualize
Jul 20 2017 18:22
@just1witness Works for me.
just1witness
@just1witness
Jul 20 2017 18:22
@revisualize Thank you!
Joseph
@revisualize
Jul 20 2017 18:23
@camperbot You worthless bucket of rust.
May Kittens Devour Your Soul
@diomed
Jul 20 2017 18:25
hahaha... classic camperbot
he's deaf, u know... @revisualize like teens :yum:
Manish Giri
@Manish-Giri
Jul 20 2017 18:27
such thirst for cookies..
:P
Anyhow.
catapulto
@catapulto
Jul 20 2017 18:32
@sjames1958gm glad you are not frustrated
@revisualize such a cookie thirst you are?
May Kittens Devour Your Soul
@diomed
Jul 20 2017 18:34
“It doesn't matter if a cat is black or white, so long as it catches mice.”
catapulto
@catapulto
Jul 20 2017 18:34
what if white cat catch black
Joseph
@revisualize
Jul 20 2017 18:34
@catapulto I don't care about the cookies. If I was here for cookies. I'd sit in the main room and just tell all of the new people... Hello and Welcome. :wave: ... A person gets far more brownie points from just welcoming new people than from helping people.
catapulto
@catapulto
Jul 20 2017 18:34
mice and black cat catch white mice.
@revisualize soorry for that
i think you are annoyed.
Joseph
@revisualize
Jul 20 2017 18:36
I'm not annoyed.
I'm typing with one broken wrist. It's slow for me to do.
catapulto
@catapulto
Jul 20 2017 18:38
@revisualize again sorry for not knowing the whole situation and barge in like that.
Joseph
@revisualize
Jul 20 2017 18:39
20046424_10157160110096959_2566518368306639058_n.jpg
I broke my wrist on June 29th. Had a dr appt on June 30th. Was in surgery on July 3rd.
I shattered an inch and a quarter of my radius.
catapulto
@catapulto
Jul 20 2017 18:41
how this happened ? btw @revisualize
Joseph
@revisualize
Jul 20 2017 18:41
bicycle
I should do a write up about it.
William/RipCrip
@RipCrip
Jul 20 2017 18:42
Doing jQuery having trouble targeting all even numbers
$("target:nth-even").addClass("animated shake");
nvm
catapulto
@catapulto
Jul 20 2017 18:43
what if i dont initialise a variable with a value but multply it with some other variable which is intialised with 1 in a loop
what will happen?
Joseph
@revisualize
Jul 20 2017 18:44
@catapulto got a code example?
catapulto
@catapulto
Jul 20 2017 18:44
yup
Joseph
@revisualize
Jul 20 2017 18:44
I think the variable becomes a global.
May Kittens Devour Your Soul
@diomed
Jul 20 2017 18:44
@revisualize are u android now? :smile:
catapulto
@catapulto
Jul 20 2017 18:44

function factorialize(num) {
var f;
for (var i=1;i>=num;i++){
f*=i;
}
return f;
}

factorialize(5);

@revisualize
Joseph
@revisualize
Jul 20 2017 18:44
@catapulto undefined * 1
catapulto
@catapulto
Jul 20 2017 18:45
i didnt initialise f with any value
and its not working
Joseph
@revisualize
Jul 20 2017 18:45
@catapulto f is undefined
catapulto
@catapulto
Jul 20 2017 18:45
okay undefined i got it
@revisualize thanks
CamperBot
@camperbot
Jul 20 2017 18:45
catapulto sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4365 | @revisualize |http://www.freecodecamp.com/revisualize
catapulto
@catapulto
Jul 20 2017 18:45
e
Joseph
@revisualize
Jul 20 2017 18:45
Set f to 0
Err
May Kittens Devour Your Soul
@diomed
Jul 20 2017 18:45
@revisualize :bicyclist: is dangerous . I nearly broke my arm in march.
catapulto
@catapulto
Jul 20 2017 18:45
nope to 1
Joseph
@revisualize
Jul 20 2017 18:45
Set f to 1
@diomed My issue is because some "lovely individual" flew by me on a bike and didn't notify. The guy was inches from me and I though he was going to hit my ass.
catapulto
@catapulto
Jul 20 2017 18:47
still not working?
@catapulto Your condition is wrong.
catapulto
@catapulto
Jul 20 2017 18:48
@revisualize how ?
Joseph
@revisualize
Jul 20 2017 18:49
if i is greaterthan or equal to num
it should be if i is lessthan or equal to num
May Kittens Devour Your Soul
@diomed
Jul 20 2017 18:49
how does 1 notify???
Joseph
@revisualize
Jul 20 2017 18:49
@catapulto
May Kittens Devour Your Soul
@diomed
Jul 20 2017 18:49
without startling you
Joseph
@revisualize
Jul 20 2017 18:50
@diomed When you pass someone on a bike you ring your bell or you say... On your left... On your right.
@diomed You don't just fly past someone at 20 mile per hour.
catapulto
@catapulto
Jul 20 2017 18:50
@revisualize okay
May Kittens Devour Your Soul
@diomed
Jul 20 2017 18:51
oh, so he passed ... and how did u fall? thinkmoji
catapulto
@catapulto
Jul 20 2017 18:51
at last i programmed it.
thanks @revisualize
CamperBot
@camperbot
Jul 20 2017 18:51
catapulto sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: catapulto already gave revisualize points
Joseph
@revisualize
Jul 20 2017 18:53
@diomed Look, he passed me going fast... And he was inches from me. I thought he was going to hit me. So, I swerved to not get hit. ... I had my big 35 - 40lbs backpack strapped to the back of my bike and I had a backpack on with sailing gear in it. When I leaned to not get hit by the guy ... I started to lose control. And when my front tire hit grass from the wobble... I went up and over.
@diomed Also, the ground was wet.
May Kittens Devour Your Soul
@diomed
Jul 20 2017 18:55
oh,yeah, that's bad situation all over.
Joseph
@revisualize
Jul 20 2017 18:55
Yeah.
May Kittens Devour Your Soul
@diomed
Jul 20 2017 18:56
damn, seems like plenty of bad things happen lately. hope u heal ASAP
Joseph
@revisualize
Jul 20 2017 18:56
Oh, it screwed up my whole summer.
I was supposed to go on 3 large sailboat races.
May Kittens Devour Your Soul
@diomed
Jul 20 2017 18:56
yeah, having arm disabled is really awful annoyance
Joseph
@revisualize
Jul 20 2017 18:58
@diomed I was supposed to be crew on a boat for the Cow Bay Regatta
May Kittens Devour Your Soul
@diomed
Jul 20 2017 18:58
damn shame
Stephen James
@sjames1958gm
Jul 20 2017 19:00
@revisualize Did you get any cool gadgets install in your wrist?
May Kittens Devour Your Soul
@diomed
Jul 20 2017 19:01
well, didn't u see the pic above?
that1 seems interesting
Joseph
@revisualize
Jul 20 2017 19:02
@sjames1958gm screws, plate and pin.
Stephen James
@sjames1958gm
Jul 20 2017 19:03
@revisualize Looks and sounds painful.
Brianna
@brisourceful
Jul 20 2017 19:40
Is anyone familiar with WebKit? For example this code:
    box-sizing:border-box;
    -webkit-box-sizing:border-box;
    -moz-box-sizing:border-box;
    -webkit-font-smoothing:antialiased;
    -moz-font-smoothing:antialiased;
    -o-font-smoothing:antialiased;
    font-smoothing:antialiased;
    text-rendering:optimizeLegibility;
Allen
@allensoberano
Jul 20 2017 19:48
Anyone know why my bootstrap cards have no spacing between them vertically? Working on the wiki Viewer: https://codepen.io/asoberano/pen/qjeBzN/?editors=1111
I added a space div with grey background but doesn't go 100% across and feel like even if it did work that would just be a hack and not explain why there isn't a space between cards without it.
Pieter Stokkink
@forkerino
Jul 20 2017 19:49
So..... I wrote my first Codewars kata the other day. If anyone wants to solve a puzzle: https://www.codewars.com/kata/one-line-wonder-sum-all-even-fibonacci-numbers/train/javascript
levani452000
@levani452000
Jul 20 2017 19:50
https://codepen.io/clevani/pen/MoNaNM why font-size is not responding to p element?
May Kittens Devour Your Soul
@diomed
Jul 20 2017 19:50
sumAllEvenFibonacciNumbers = n => // this be so hard!
Pieter Stokkink
@forkerino
Jul 20 2017 19:51
:trollface:
actually, it's not the worst.
May Kittens Devour Your Soul
@diomed
Jul 20 2017 19:52
@levani452000 ummm... coz u didn't set it to be for p element anywhere in css?
Ogundele Olumide
@Lumexralph
Jul 20 2017 19:53
@forkerino i'll ask for the challenge link the day I return to war
levani452000
@levani452000
Jul 20 2017 19:53
ooh no thanks
Pieter Stokkink
@forkerino
Jul 20 2017 19:53
@Lumexralph peace be upon you, my friend.
May Kittens Devour Your Soul
@diomed
Jul 20 2017 19:54
we need more answrs , not questions :yum:
Pethaf
@Pethaf
Jul 20 2017 19:57
First we have to establish if an answer does exist.
Ogundele Olumide
@Lumexralph
Jul 20 2017 19:59
@forkerino and unto you my good friend
Pieter Stokkink
@forkerino
Jul 20 2017 19:59
:pray:
Adit
@adittyagi
Jul 20 2017 20:00
Hey guys, why do we first convert string into an array to reverse the string ?
Ogundele Olumide
@Lumexralph
Jul 20 2017 20:00
:bow:
May Kittens Devour Your Soul
@diomed
Jul 20 2017 20:01
Write a function to help Marty send a message to Doc.
FML
Pethaf
@Pethaf
Jul 20 2017 20:01
@forkerino Is there a limit on how many character per line?
Ogundele Olumide
@Lumexralph
Jul 20 2017 20:02
@adittyagi because reverse is not a string method
Pieter Stokkink
@forkerino
Jul 20 2017 20:02
@adittyagi because .reverse() is an array method. It doesn't work on strings.
@Pethaf 76 (or less) characters in total
Adit
@adittyagi
Jul 20 2017 20:02
@Lumexralph @forkerino oh okay. Thank you guys!
CamperBot
@camperbot
Jul 20 2017 20:02
adittyagi sends brownie points to @lumexralph and @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2875 | @forkerino |http://www.freecodecamp.com/forkerino
:star2: 2040 | @lumexralph |http://www.freecodecamp.com/lumexralph
EpicTriffid
@EpicTriffid
Jul 20 2017 20:03
Im having real difficulty working out how to filter my results based on the buttons. I feel like i'm missing something obvious? https://codepen.io/EpicTriffid/pen/rwEmgQ
Pethaf
@Pethaf
Jul 20 2017 20:05
@EpicTriffid Do you use some kind of class to distinguish active/inactive twitch users?
When displaying all of them?
Manish Giri
@Manish-Giri
Jul 20 2017 20:06

@forkerino

Sum and return all even Fibonacci numbers

what is the expected return? an array of numbers?

Joseph
@revisualize
Jul 20 2017 20:06
@EpicTriffid Have you looked at your developer console?
Chris
@bestintown23
Jul 20 2017 20:06
why is my nav bar not aligned to be on one line?? https://codepen.io/bestintown23/pen/owKqyj
Ogundele Olumide
@Lumexralph
Jul 20 2017 20:10
@Manish-Giri sggggggggm :smiling_imp:
Pieter Stokkink
@forkerino
Jul 20 2017 20:11
@Manish-Giri the sum!
@Manish-Giri thanks, I changed the instructions to make it more clear.
CamperBot
@camperbot
Jul 20 2017 20:13
forkerino sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6288 | @manish-giri |http://www.freecodecamp.com/manish-giri
May Kittens Devour Your Soul
@diomed
Jul 20 2017 20:17
@Manish-Giri === js wiz
Brianna
@brisourceful
Jul 20 2017 20:17
@bestintown23 you have a ton of classes with no styling and a bunch of styling with no classes added to your html. You are trying to get X.Finero.X and your icons all on on the same "line"?
May Kittens Devour Your Soul
@diomed
Jul 20 2017 20:20
does this site work 4 any1 else: http://animista.net
in terms of downloading favorited code
Brianna
@brisourceful
Jul 20 2017 20:20
@bestintown23 first off your #navtext class should be inline not block
Chris
@bestintown23
Jul 20 2017 20:32
@brisourceful well this is from my actual code on notepad ++
@brisourceful yes i am
EpicTriffid
@EpicTriffid
Jul 20 2017 20:39
@Pethaf I set the status to offline/online depending on if the stream in null
@revisualize yeah, it brings up errors about channel not be valid for null
ajdev27
@ajdev27
Jul 20 2017 20:44
can someone help me?
Aita Kane
@aita-kane
Jul 20 2017 20:44
hello can someone help me please i try to apply a background color on hover but nothing appear
ajdev27
@ajdev27
Jul 20 2017 20:44
function factorialize(num) {
  var counter = 1;
  for (var i = 2; i < num; i++) {
    counter = counter * i;
  }
 return counter;
}

document.write(factorialize(8))
im trying to get the factorial number of num but it doesnt come out to the right one
like when i put 8 as an argument it comes out as 5040
Pieter Stokkink
@forkerino
Jul 20 2017 20:45
@ajdev27 you don't multiply by num
the loop stops too soon
ajdev27
@ajdev27
Jul 20 2017 20:45
instead of the correct factorial 40320
@forkerino what do you mean?
__mifflin__
@cdrainxv
Jul 20 2017 20:53
@ajdev27: Your loop only multiplies to one less than the number… for factorialize(8) you only multiply up to 7, but not 8. You need i <= num… to include multiplying num as well.
Pieter Stokkink
@forkerino
Jul 20 2017 20:55
i<numprevents your loop from multiplying by num
ajdev27
@ajdev27
Jul 20 2017 20:56
@cdrainxv @forkerino thanks guy appreciate it
CamperBot
@camperbot
Jul 20 2017 20:56
ajdev27 sends brownie points to @cdrainxv and @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2876 | @forkerino |http://www.freecodecamp.com/forkerino
:star2: 2768 | @cdrainxv |http://www.freecodecamp.com/cdrainxv
Jake
@JakeDVirus
Jul 20 2017 21:06
given is my random quote machine challenge.
the only issue i am getting is in tweet button. the event handler or something is not working.
can anyone help? :/
https://codepen.io/neel111/pen/dRBQNY
pacbac
@pacbac
Jul 20 2017 21:14
Imo the on() method is easier to use
$("button").on("click", function(){ stuff });
it's jquery though, but jquery makes the code much more concise
Joseph
@revisualize
Jul 20 2017 21:18
if (condition) {
     true statement:
} else {
     false statement;
}

....

(condition) ? true statement : false statement;

...
There is NO way to make an else if in a ternary operator.
If you were to do something like this:

if (conditionOne) {
     if (conditionTwo) {
         two true statement:
     } else {
        two false statement;
     }
} else {
     one false statement;
}

...

(conditionOne) ? (conditionTwo) ? two true statement : two false statement : one false statement;
...
Note: This commentary above isn't related to anything in chat. I needed to make a screenshot and I'm just going to leave it.
Gulsvi
@gulsvi
Jul 20 2017 21:34
@revisualize I'm guessing it comes down to semantics? This is certainly an else if ternary depending on your point of view:
myVar = (a == 1) ? 'a' : (a == 2) ? 'aa' : 'b';
^^ equivalent:
if(a == 1) {
  myVar = "a";
} else if(a == 2) {
  myVar = "aa";
} else {
  myVar = "b";
}
Joseph
@revisualize
Jul 20 2017 21:38
@SkyC0der But, that is still written as...
if (a == 1) {
  myVar = 'a';
} else {
    if (a == 2) {
        myVar = "aa";
    } else {
        myVar = "b";
    }
}
Gulsvi
@gulsvi
Jul 20 2017 21:40
Right, so it depends on your point of view :)
It can also be written as:
myVar = "b";
if(a == 1) myVar = "a";
if(a == 2) myVar = "aa";
Joseph
@revisualize
Jul 20 2017 21:43
Not with a ternary
Gulsvi
@gulsvi
Jul 20 2017 21:46
What's an example where a ternary would fail because we expect it to mean else if () {} instead of else { if () {}}?
Joseph
@revisualize
Jul 20 2017 21:47
Look.
This was the question: can I use ternary (?) instead of else if ?
The answer is no.
I'm not here to argue symantics
Gulsvi
@gulsvi
Jul 20 2017 21:48
not arguing, just trying to understand why that answer would be no, i.e. why wouldn't that work?
eeflores
@eeflores
Jul 20 2017 21:48
you probably don't want to make a ternary too complicated ... too much to decipher on one line
Gulsvi
@gulsvi
Jul 20 2017 21:48
Completely agree that ternary statements are hard to decipher :)
eeflores
@eeflores
Jul 20 2017 21:51
I remember someone in the chat that wanted to reduce the number of code lines by making them longer
thought it would make it easier somehow
or more efficient?
Gulsvi
@gulsvi
Jul 20 2017 21:52
sometimes we can get carried away trying to make our code look concise :)
I don't think I'd recommend a ternary for anything but a simple if/else
Kyle Holm
@thekholm80
Jul 20 2017 21:53
I hate seeing ternaries nested more than 2 deep
Joseph
@revisualize
Jul 20 2017 21:55
I don't like seeing ternaries.
code really should be human readable.
Kyle Holm
@thekholm80
Jul 20 2017 21:56
sometimes they can't be avoided
Gulsvi
@gulsvi
Jul 20 2017 21:56

Me too, I am genuinely curious why this:

if (a == 1) {
  myVar = 'a';
} else {
    if (a == 2) {
        myVar = "aa";
    } else {
        myVar = "b";
    }
}

is different than:

if(a == 1) {
  myVar = "a";
} else if(a == 2) {
  myVar = "aa";
} else {
  myVar = "b";
}

and why this ternary can only represent the former:

myVar = (a == 1) ? 'a' : (a == 2) ? 'aa' : 'b';
Kyle Holm
@thekholm80
Jul 20 2017 21:57
looks like they achieve the same thing
eeflores
@eeflores
Jul 20 2017 22:02
switch statement?
Kyle Holm
@thekholm80
Jul 20 2017 22:02
writing switch statements with multiple evaluations is a pain in the butt
iirc it will only work if with switch (boolean) { case *logic*: etc
eeflores
@eeflores
Jul 20 2017 22:04
switch(a) {
  case 1: myVar = "a"; break;
  case 2: myVar = "aa"; break;
  default: myVar = "b";
}
Kyle Holm
@thekholm80
Jul 20 2017 22:04
yeah that will work
but it has to be a straight this === that kind of statement
eeflores
@eeflores
Jul 20 2017 22:05
I don't like having multiple statements on the same line though, so I would typically take more lines for this
Gulsvi
@gulsvi
Jul 20 2017 22:06
I like the object approach - if it were bigger:
var myObj = {
  1: 'a',
  2: 'aa'
}
var myVar = myObj[a] || 'b';
eeflores
@eeflores
Jul 20 2017 22:06
key value map also ... ah I was just about to suggest that
Kyle Holm
@thekholm80
Jul 20 2017 22:06
default values are so awesome
eeflores
@eeflores
Jul 20 2017 22:07
wow that'll work in JS?
Kyle Holm
@thekholm80
Jul 20 2017 22:07
yeah, if myObj[a] evaluates as undefined it will default to 'b'
eeflores
@eeflores
Jul 20 2017 22:08
noice
Gulsvi
@gulsvi
Jul 20 2017 22:26
so basically, another one-liner :)
var myVar = {1: 'a', 2: 'aa'}[a] || 'b';
Kyle Holm
@thekholm80
Jul 20 2017 22:26
that's actually pretty slick
Gulsvi
@gulsvi
Jul 20 2017 22:26
I kind of like it too lol
prettier than
myVar = (a == 1) ? 'a' : (a == 2) ? 'aa' : 'b';
Kyle Holm
@thekholm80
Jul 20 2017 22:27
don't know if i'd ever use it, but it's fun to look at
mstellaluna
@mstellaluna
Jul 20 2017 22:27
@Manish-Giri ty !
CamperBot
@camperbot
Jul 20 2017 22:27
mstellaluna sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6289 | @manish-giri |http://www.freecodecamp.com/manish-giri
Kyle Holm
@thekholm80
Jul 20 2017 22:28
i was just thinking Manish needed more cookies
eeflores
@eeflores
Jul 20 2017 22:33
about @rphares
CamperBot
@camperbot
Jul 20 2017 22:33
:star2: 6593 | @rphares |http://www.freecodecamp.com/rphares
eeflores
@eeflores
Jul 20 2017 22:33
so has anyone overtaken her yet?
Kyle Holm
@thekholm80
Jul 20 2017 22:34
yeah, what's-his-face-st-james is over 8k
Joseph
@revisualize
Jul 20 2017 22:38
about @sjames1958gm
CamperBot
@camperbot
Jul 20 2017 22:38
:star2: 8123 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Joseph
@revisualize
Jul 20 2017 22:39
about @Manish-Giri
CamperBot
@camperbot
Jul 20 2017 22:39
:star2: 6289 | @manish-giri |http://www.freecodecamp.com/manish-giri
Joshua Waller
@Obscureether1
Jul 20 2017 23:28
all hows it going
Stephen James
@sjames1958gm
Jul 20 2017 23:33
@Obscureether1 hello
Razvan
@razvanlikespizza
Jul 20 2017 23:46
Wrong chat.
tao
@Azerop
Jul 20 2017 23:47
Screen Shot 2017-07-21 at 7.46.17 AM.png
how can i understand this Pattern and Inserts
Stephen James
@sjames1958gm
Jul 20 2017 23:57
@Azerop You could try some matches where the replace only has these values
"111151111".replace(/5/, "$$"); // 5 is replaced by $
"1111$1111"
"111151111".replace(/5/, "$&"); // 5 is replaced by the match, which is 5
"111151111"
"111152222".replace(/5/, "$`"); // 5 is replaced by the 1111 which is before the 5
"111111111111"
"111152222".replace(/5/, "$'"); // 5 is replaced by the 2222 which is aftger the 5
"111122222222"
"123456789".replace(/(5)(6)/, "$2$1"); // 5 and 6 are matches $1 and $2 so they are swapped
"123465789"