Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jun 19 2020 20:09
    @krisb1220 banned @Gastony
  • May 14 2020 22:39
    @bjorno43 banned @minitechtips_twitter
  • May 14 2020 22:38
    @bjorno43 banned @real-action
  • Feb 01 2020 00:27
    @bjorno43 banned @Ndoua
  • Jan 07 2020 03:10
    @bjorno43 banned @doctor-sam
  • Aug 17 2019 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 2019 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 2019 17:13
    @mstellaluna banned @cmal
  • Jan 08 2019 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
John Nunns
@johnnunns
function convertObjectToList(obj) {
  for(var i in obj){
    obj.push([i])
  }

}
JD Tadlock
@jdtdesigns
because obj is not an array @johnnunns
@MohammadHasham I'm telling you this because if you go back and DRY it now, you'll most likely find the issue ;)
Muhammad Hasham
@MuhammadHasham23
how can i DRY this up.By using predefined functions or what?
JD Tadlock
@jdtdesigns
@MohammadHasham Don't forget you have the awesome 'this' in any event function
Muhammad Hasham
@MuhammadHasham23
okay @jdtdesigns Thank
JD Tadlock
@jdtdesigns
So instead of creating an if for each button, just use 'this' to refer to the button clicked
CamperBot
@camperbot
:cookie: 859 | @jdtdesigns |http://www.freecodecamp.com/jdtdesigns
mohammadhasham sends brownie points to @jdtdesigns :sparkles: :thumbsup: :sparkles:
JD Tadlock
@jdtdesigns
also, since elements in the DOM all have index values, you can use those too
John Nunns
@johnnunns
yeah man I've hit a wall then I'm afraid @jdtdesigns
not sure how to use a push if it's not an array. Common logic would tell me I have to make it an array first before I can push an array on it
JD Tadlock
@jdtdesigns
@johnnunns You'll need to create an empty array inside the function that you can push to. The 'obj' is referring to the object being passed into the function.
John Nunns
@johnnunns
gotcha. like a var x = []
JD Tadlock
@jdtdesigns
@johnnunns right ;)
Sorin Ruse
@sorinr
@johnnunns failure in web dev its mother of learning. don't be afraid that u can fail. :)
alpox
@alpox
@sorinr Failure everywhere is :D
John Nunns
@johnnunns
@sorinr life lessons :)
function convertObjectToList(obj) {
  for(var i in obj){
    var x = []
    x.push(obj[i])
  }

}

convertObjectToList(obj)
Sorin Ruse
@sorinr
@alpox if you keep go on and improve your coding its not
John Nunns
@johnnunns
wait I think i see it hold on
JD Tadlock
@jdtdesigns
@johnnunns You're getting close
John Nunns
@johnnunns
function convertObjectToList(obj) {
  for(var i in obj){
    var x = []
    x.push(obj[i])
  }
  return obj
}

convertObjectToList(obj)
JD Tadlock
@jdtdesigns
nope :P
John Nunns
@johnnunns
so when I run it I'm still returning the exact same object haha
JD Tadlock
@jdtdesigns
the empty array should be outside the for loop
and you'll be returning the array, not the obj
because the whole goal is to convert the object to an array :P
asmaamoussa
@asmaamoussa
Hello;
I am almost done with my pen. plz let me know ur opinion and I also want to know how to center align the social media buttons at the very end?
John Nunns
@johnnunns
var x = []
function convertObjectToList(obj) {
  for(var i in obj){

    x.push(obj[i])
  }

  return x
}

convertObjectToList(obj)
JD Tadlock
@jdtdesigns
@johnnunns Not outside the function, just above the for loop
And you're pushing an array to the array, not just the value
and the array's first value will be the property and the second value is the object value
John Nunns
@johnnunns
oh wow
function convertObjectToList(obj) {
    var x = []
  for(var i in obj){

    x.push([i,obj[i]])
  }

  return x
}

convertObjectToList(obj)
I think I did it?
Sorin Ruse
@sorinr
@asmaamoussa as i said yesterday using same colors fur the buttons in the nav as you have the on the picture's doors it will make sense to the user that clicking that button will open a specific door (get some specific info)
JD Tadlock
@jdtdesigns
;)
@johnnunns
John Nunns
@johnnunns
ok, here's the barrage of questions now :)
i by itself equaled all of the values in the object correct?
JD Tadlock
@jdtdesigns
the properties
John Nunns
@johnnunns
only the properties?
JD Tadlock
@jdtdesigns
yep
John Nunns
@johnnunns
so if i console.log(i) it would just be name, age, etc
JD Tadlock
@jdtdesigns
correct
John Nunns
@johnnunns
ok, well that's that then
because it makes sense to me that obj[i] then equals the values