Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
Muhammed Hafiz
@zifahm
@ehutchllew hmm
ehutchllew
@ehutchllew
@zifahm ugh i figured it out
i'm so dumb, forgot about it.
Stephen James
@sjames1958gm
@zifahm Your maps need return if you use {} for arrow functions
ehutchllew
@ehutchllew
@sjames1958gm tried with return as well, nothing. I did this and it worked:
_getRecipeTitles(){
    let arr = [];
    this.state.recipes.forEach((item) => {
      arr.push(<h1>{item.title}</h1>)
    });
    return arr;   
  }
I forgot that react renders elements/components in arrays.
Muhammed Hafiz
@zifahm
@sjames1958gm @ehutchllew ohhh
return
Stephen James
@sjames1958gm
@zifahm If you use () then it automatically returns
Muhammed Hafiz
@zifahm
@sjames1958gm @ehutchllew thank you so much guys
CamperBot
@camperbot
zifahm sends brownie points to @sjames1958gm and @ehutchllew :sparkles: :thumbsup: :sparkles:
api offline
:star2: 8865 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
ehutchllew
@ehutchllew
@zifahm did it work with just a return or did it require an array as well?
Muhammed Hafiz
@zifahm
ehutchllew
@ehutchllew
sweet
Muhammed Hafiz
@zifahm
:)
Stephen James
@sjames1958gm
@zifahm I forget that often, so I saw it pretty quickly :)
Muhammed Hafiz
@zifahm
@sjames1958gm :)
dinesh
@1532j0004kg
hi james
yogiwhocodes
@yogiwhocodes
Hi everyone, just discovered this chat here and don't know if this is the right place to ask... I'm working on the random quote machine and I'm stuck with my twitter button. I wanna use the .attr method to push the quote into the twitter 'data-text' field but can't figure out how to implement it. Could somebody maybe help me out there? This is my codepen (please ignore the design!) https://codepen.io/yogiwhocodes/pen/ZvOmyd
Ken Haduch
@khaduch
@yogiwhocodes - hello. Not sure about the twitter button just yet, but looking at the page. One suggestion - get a quote to populate your quote box or put some text in there to begin with - maybe a favorite quote? And something like "Click the button for new quotes"... ?
Ken Haduch
@khaduch
@yogiwhocodes - one problem is that there is no button or element with the id twitter-btn, at least it doesn't appear to be there? I think that after running that twitter code, it makes its own element on the page. Going to look at the docs to see how they recommend updating it.
Aditya
@ezioda004
@khaduch There is an <a> with that id, trying to debug too but no idea why it is acting this way.
Ken Haduch
@khaduch
@ezioda004 - I've been confused about this twitter intent thing for a while. I found another method to do it, but this seems like a way that is supposed to work. Still looking... @yogiwhocodes
Aditya
@ezioda004
@khaduch I meant this code is weird like I commented the whole $("#twitter-btn") click event out and its still working like before
I think its because of this part of the code
window.twttr = (function(d, s, id) {
  var js,
    fjs = d.getElementsByTagName(s)[0],
    t = window.twttr || {};
  if (d.getElementById(id)) return t;
  js = d.createElement(s);
  js.id = id;
  js.src = "https://platform.twitter.com/widgets.js";
  fjs.parentNode.insertBefore(js, fjs);

  t._e = [];
  t.ready = function(f) {
    t._e.push(f);
  };
  return t;
})(document, "script", "twitter-wjs");
Ken Haduch
@khaduch

@ezioda004 @yogiwhocodes - that is what I was referring to in my comment about "twitter code". I have something that works, based on information that I found on stackoverflow. It doesn't style the button, but I think that you can make the HTML code to do that. This is something that updates the link with the new tweet (some formatting, like removing the <p> tags) would be a good thing to do.

        var tbutton = $('.twitter-share-button');
        var theQuote = encodeURIComponent(receivedQuote[0].content + receivedQuote[0].title);
        tbutton.attr('href', 'https://twitter.com/intent/tweet?text=' + theQuote);

See if that works for you?

Aditya
@ezioda004
@khaduch Yeah this'd work but isnt windows.open better to use instead of changing the href of the anchor tag? Cause apparently @yogiwhocodes was also going for that (last part of the code)
Ken Haduch
@khaduch

@ezioda004 - well, I should have added that I changed the code for the button to add a target="_blank" into the anchor, so that it would open in a separate window.

One thing to be cautious of, in the way that @yogiwhocodes is trying to do it, is that this code:

$("#twitter-btn").on("click", function() {
  window.open(
    "https://twitter.com/intent/tweet?text=" +
      encodeURIComponent($("#quote").text())
  );

would have to be run every time you get a new quote because it is only setting up the click handler one time. And you would have to make sure to remove the click handler prior to updating the new one. Running that twitter intent code (the code that you posted above) to me seems to be geared to building a single tweet button that sends pre-determined text. Not to say that it cannot be made to work, but it seems that the method that I posted above (taken from that stackoverflow post and massaged a little) can be made to work. Maybe there is a better twitter method to do what you and @yogiwhocodes are trying to do?

Ken Haduch
@khaduch

@ezioda004 @yogiwhocodes - okay, one more pass at this, after a little more thought. I removed the code that I added in this post (from my working copy of the quote button) :point_up: January 17, 2018 1:49 PM and modified the click handler to look like this:

$("#twitter-btn").on("click", function() {
  var getQuote = encodeURIComponent($("#quote").text())
  window.open(
    "https://twitter.com/intent/tweet?text=" + getQuote

  );
});

So that it actually reads the #quote text from the HTML DOM. And that seems to work, at least it gets the updated quotes. Still doesn't have the pretty twitter button, but the HTML could be tweaked. Or maybe it will play nicely with the twitter code? (No, it won't work once you run that twitter function... so I'm leaving it as I had it. I'll save a fork of @yogiwhocodes pen and I have to go and shovel some snow...)

Aditya
@ezioda004
@khaduch Yes, thats how I did too, you get the text() from the <p> or whatever you stored them in
Ken Haduch
@khaduch
@yogiwhocodes @ezioda004 - this is the forked copy of the pen that is mostly working - just for reference
Tychro van den Broeke
@tychro
does anyone know how to get the time and date in JS linked to my HTML?
Aditya
@ezioda004
Current time?
Tychro van den Broeke
@tychro
yes
and the date
yozhikvtumane
@yozhikvtumane
Hello! I am currently doing Twitch project and I subscribed to FreeCodeCamp channel, but I can't see it in object I get from the server
Aditya
@ezioda004
@tychro
var d = new Date();
var n = d.getDate();
To get the current date
Tychro van den Broeke
@tychro
is time the same?
Aditya
@ezioda004

Kinda, you'd have to do something like

d.getHours(); 
d.getMinutes(); 
d.getSeconds();

and concatenate them

@yozhikvtumane Can you post your codepen link?
Kaz Baig
@kbaig
There's also a bunch of methods on Date to get the string in different formats, found in the Conversion getter section of the Date documentation
Aditya
@ezioda004
^
yozhikvtumane
@yozhikvtumane
Aditya
@ezioda004
@yozhikvtumane Dont think they let you see the subscribers of a channel, you can only see followers
yozhikvtumane
@yozhikvtumane
I am trying to get what the task is asking for