Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
  • 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
:star2: 1158 | @marmiz |http://www.freecodecamp.org/marmiz
Dany Din
@SweetCodingInc thx budddy
danydin sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
api offline
Claudio Restifo
@Philominsuji because i increments, so your j loops more on each iteration.
i = 0 --> j(1) <= 0 is false so nothing happens
i =1 --> j(1) <= 1 loop one time
i = 2 --> j(1) <= 2 loop two times (first time j = 1; then j =2)
i = 3 --> j(1) <= 3 loop three times ( j= 1; j=2; j=3)

[... and so on..]
i = 6 breaks the loop
Michael Cordero
anyone familiar with react and CORS?
Sweet Coding :)
@CyberPutty yes?
Michael Cordero
@SweetCodingInc cool. I'm using react in VSC and when i try a fetch i get a console error about not allowing CORS because i need Access-Control-Allow-Origin: *. where do i write that?
Sweet Coding :)
@CyberPutty what URL are you trying to fetch?
Michael Cordero
just a github file
Sweet Coding :)
can you share code ?
Michael Cordero
but im running locally on port#
const url= "https://github.com/lewagon/flats-boilerplate/blob/master/flats.json";
  .then(response=> response.json())
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://github.com/lewagon/flats-boilerplate/blob/master/flats.json. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
Sweet Coding :)
@CyberPutty correct
you need to use the raw url https://raw.githubusercontent.com/lewagon/flats-boilerplate/master/flats.json
the url you've specified is an actual html page and not a json.
Michael Cordero
@SweetCodingInc lawl kk im try that first.
Sweet Coding :)
When you visit this file https://github.com/lewagon/flats-boilerplate/blob/master/flats.json there are 3 buttons on right side right above where the code starts. Click on Raw button that will take you to actual file
Michael Cordero
@SweetCodingInc Thanks' that worked.
cyberputty sends brownie points to @sweetcodinginc :sparkles: :thumbsup: :sparkles:
:cookie: 285 | @sweetcodinginc |http://www.freecodecamp.org/sweetcodinginc
Sweet Coding :)
use that url
@CyberPutty :+1:

Hello! I am making filtering table with ReactJS, and now I have something like that:

export function searchPlayersConfigs(string) {
  if (string === '') {
    return playersConfigCache;

  const searchResult = [...playersConfigCache];
  return searchResult.filter(config => config.name.toLowerCase().indexOf(string.toLowerCase()) !== -1);

how to make exact matches appear first, after that matches which begin with search string, and last ones that contain search string?

@YVeselovskyi how about checking if all chars match? Then it's a perfect match.
Stephen James
@YVeselovskyi You might need to use sort after filter. Putting exact first, then lower indexOf result next
Roman Struna
Hey everyone, I would love it if someone with a lot of experience would help me optimize this project :)
It works, but perhaps I complicated it a bit too much so I can apply the style it has ¯_(ツ)_/¯
@Marmiz So, it is just node.js trying to keep their way, that has nothing to with difference in es6 or es5?
anyone know ow to do this with JS?
Stephen James
@RomchyFCC One thing I would do is nest the channels getJSON in the streams getJSON callback.
Because you are subject to all sorts of out of order issues. Also, eliminate the
setTimeouts, they are also sensitive to network delays.
array = []
for each channel
     $getJSON for stream
          $getJSON for channel
               push data to array
               if (array.length == channels.length) process data from array // you have all the data
Roman Struna
wouldn't the code quit if the stream was offline then? stream is offline and the data is incomplete -> would never fire the call for channel if the channel was in the callback?
the problem is that i need the setTimeouts, because i need order, and if I omit the timeouts, the order gets mixed up and the design is ruined, this assignment would be super easy if i didn't care about order
Stephen James
@RomchyFCC You get the channel data for every channel already - regardless of online/offline
Roman Struna
that's true but the stream data is different than channel data, i need every channel data so i can display the channel info such as name and link
if i use stream data i don't get those 2
and the stream is offline, if the stream is online i get all the info
Stephen James
@RomchyFCC With the nest calls you have access to both stream and channel data for the same channel
@RomchyFCC And if you count responses then you don't have to use timers which are prone to error
Roman Struna
indeed but wouldn't it make more sense to nest stream JSON in channel JSON
Stephen James
@RomchyFCC Yes.
Roman Struna
actually no, i don't see any of these working, best bet would be if statement and error handling i assume..which i don't know how to do well, if stream data available use it if not use channel data, wouldn't that make the most sense?
actually nesting stream data would be fine too, about the same amount of calls
would have to try it and see how it orders things
Stephen James
@RomchyFCC If you nest them, then you will have all the data needed in the innermost response to process both stream and channel data.
And you order the data just like you do in the setTimeout.
Rohit kumar
I am working on freeCodeCamp redesign concept on my own. The first version will be complete until next week. It would be great if you review it. https://www.figma.com/file/cBad9b0LaMd1TM8Kcde7im1n/fcc https://www.figma.com/file/cBad9b0LaMd1TM8Kcde7im1n/fcc?node-id=26%3A2 https://www.figma.com/file/cBad9b0LaMd1TM8Kcde7im1n/fcc?node-id=15%3A4573
looks good @Rohitkrops
Roman Struna
i'll look into nesting them if i get any time off, will let you know how it goes, also, i didn't like the timeout sollution but nothing else i tried worked, thanks for the feedback @sjames1958gm i'll try to fix it asap
romchyfcc sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: