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
George Kemp
@gkemp94
How can I make sure all requests have finished?
mpontus
@mpontus
You could use Promise.all
Promise.all(arrayOfPromises).then(functionToInvokeAfterAllPromisesHaveBeenFulfilled)
But first you need to construct an array of promises for each request, which will be resolved after each of them has finished
@gkemp94 I would start by making your getinfo function to return a Promise
piteto
@piteto
@gkemp94 From what I see, you call firstFunction() when your document is ready, that's when you try to access dataArray, but dataArray isn't populated until your second getJSON is complete processing all the users in your array
George Kemp
@gkemp94
The promise might be over my head. I was trying to use a callback but I don't think I used it correctly
piteto
@piteto
callback counters might be easier
George Kemp
@gkemp94
Is there a good resource to learn how to use promise>
piteto
@piteto
Add this to the end of your second getJSON: if(dataArray.length === userIds.length) refreshHTML()
mpontus
@mpontus
I have a mongodb question. From what I've heard it is considered a good pratice to embed user object inside the content attributed to them (such as post.author). Assuming that I follow this pattern, how do I go about renaming the user in the future? Would I have to update every piece of content ever created by this user?
piteto
@piteto
then you are guaranteed that dataArray has all the data before you call your refreshHTML function
@mpontus I think the people over in the back end room might be able to help out better: https://gitter.im/FreeCodeCamp/HelpBackEnd
mpontus
@mpontus
@piteto Thank you!
CamperBot
@camperbot
mpontus sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 145 | @piteto |http://www.freecodecamp.com/piteto
piteto
@piteto
People who know mongo do visit here though
but you're guaranteed to find knowledgeable people over there :)
@gkemp94 If this helps explain it better: https://codepen.io/anon/pen/wrzOoY?editors=0011
George Kemp
@gkemp94
@piteto oh and that's what you were saying earlier!
that makes sense
piteto
@piteto
To be honest, it makes things a little complicated to parse the data from the API and put it in another object that you have to parse all over again. It would be more efficient to grab it from the API and use it right away
George Kemp
@gkemp94
@piteto I was doing that earlier, but I'm adding a feature where you can add and subtract users, and I didn't to have to fetch the users each time you added or removed a username
I definitely made it more complicated, but I'm trying to challenge myself
piteto
@piteto
Okay, yeah, I hadn't considered that feature. Maybe you'd want to look into session storage and keep the data there instead? It would be available to your web page as long as the browser is tab is open.
Definitely good to challenge yourself - I did the bare minimum for that, might kick myself later :)
George Kemp
@gkemp94
@piteto I've kind of skimmed the past few, so I wanted to spend a lot of time on this one making sure I understand it thoroughly! Sounds like you're well ahead of it! :)
Ismail Hozain
@ismailhozain
hey could anyone help me deploy something to the web with surge from my computer
i am having issues with it because it is not showing up on the web
but it says it worke
d
but it wont let me clik on the link in my command prompt
aRtoo
@artoodeeto

hellow fam
i got the solution correct now
but i have a question
my first solution is this. i got the requirements correct except for the other one.
bob instanceof Person should return true. im getting this incorrect.

my first solution:

 /*var first = firstAndLast.split(' ')[0];
    var last = firstAndLast.split(' ')[1];

    return  {
      getFullName: function() {
        var fullName = first + ' ' + last;
        return fullName;
      },

      getFirstName: function() {
        return first;
      },

      getLastName: function() {
        return last;
      },

      setFirstName: function(newFirst) {
         first = newFirst;
      },

      setLastName: function(newLast) {
         last = newLast;
      },

      setFullName: function(newFullname) {
        first = newFullname.split(' ')[0];
        last = newFullname.split(' ')[1];
         //firstAndLast = newFullname;
      }
    };*/

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

but on my 2nd solution
this is my 2nd solution i got everything correct. i just used the .this keyword. i dont know why. i just followed the given sample that was initialize

var Person = function(firstAndLast) {

    var fname = firstAndLast.split(' ')[0];
    var lname = firstAndLast.split(' ')[1];

    //Complete the method below and implement the others similarly
    this.getFullName = function() {
      var fullname = fname + ' ' + lname;
      return fullname;
    };

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

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

    this.setFirstName = function(newFirst) {
      fname = newFirst;
    };

    this.setLastName = function(newLast) {
      lname = newLast;
    };

    this.setFullName = function(newFull) {
      fname = newFull.split(' ')[0];
      lname = newFull.split(' ')[1];
    };

};


var bob = new Person('Bob Ross');
bob.setFullName('bruh haa');
bob.getFullName();
Ismail Hozain
@ismailhozain
hmm interesting
Bhoomi Khanderia
@bhoomikhanderia
Hi ! I am trying to implement bootstrap navbar. I want my logo to be center aligned which I am not able to achieve. Can anyone please suggest the solution. Please check my code: https://codepen.io/Bhoomi/pen/QqKRQm
piteto
@piteto
@Bhoomi-Github It depends on how you want it to look. You might try this suggestion
Rohit
@Rohitvirgin
Hii
Lhagvasuren
@3lhagvaasuren
https://codepen.io/3lhagvaasuren/pen/xXEoZV
guys in this code i cant access to body. i just wanna change the background-color: black; or something but it doesnt work
please help me
Rohit
@Rohitvirgin
Try putting all code in <div> tag and add class with bg color component there
It Might work
Lhagvasuren
@3lhagvaasuren
what div?
<div class="container-fluid">
<h1 class="header">Travis<span><img class="mainPicture" src="https://ih0.redbubble.net/image.398989678.9673/ap,550x550,12x12,1,transparent,t.u1.png"></span>Scott</h1>




</div>
Rohit
@Rohitvirgin
In 2nd line, Div tag
Add another class xyz
Set background-color property of xyz to black or whatever colour u want
Kent Saeteurn
@sansae

hello, can anyone explain to me why "\n" works in one instance, but not the other?

this works:

"using newline in this manner" + "\n" +
"successfully adds a new line to this string"

however, this doesn't...

var name = SomeObjectImWorkingWith.name;
"hi, my name is " + name + "\n" +
"what is yours?"
the 2nd example, \n is literally just concatenated onto the string. why?
Kent Saeteurn
@sansae
determined the reason; it seems \n doesn't work on returns; now the question is, why? and how to get it to work on returns