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
otmeek sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 2037 | @heroiczero |http://www.freecodecamp.com/heroiczero
Victor Abeledo
Hi guys! I'm writing a function to retrieve a token from localStorage and if not there, fetch the token and store it, but I have a bug because the second if never evaluates
  this.token = localStorage.getItem('myToken');//null when not loaded
  console.log(this.token);//401 invalid acces token
  if(this.token == null){
    let possibleToken:string = window.location.href;
    let position:number = possibleToken.indexOf('access_token=')+13;//13 is the length of 'acces_token='
    let lastPos:number = possibleToken.indexOf('&token_type');
      if(lastPos !== -1){//if we have token
        this.token = possibleToken.slice(position,lastPos);
        localStorage.setItem('myToken', this.token);
(last brace is from the function ngOnInit, it launches every time you refresh page)
can anyone please help me solve this am having issues with this code of mine it's not returning the correct color all am getting is wrong
Garrus Napp
@leet-hacks hi ill take a look
Kevin K. Lee
@leet-hacks i think it has to do with your usage of this. what does this refer to you in your code?
think about the context of this in an anonymous function.
Kevin K. Lee
so when you call var clicked = this.style.backgroundColor, what is this here? what is this.style? try console logging this
also, when you are sharing your code, it's much better for everyone involved if you use a collab editor like codepen, so that someone can actually go into your code and start tweaking around. dev in whatever env you want, and copy-paste into codepen to share.
Ken Haduch
@otmeek - well, congratulations and best of luck on the job! I agree with @heroiczero - if they went through all of the process of interviewing and hiring, they will want you to succeed. You can always focus on understanding some of the bootstrap CSS techniques for the features that you find to be really helpful, so you have a better grasp on what they do in their CSS. Again - good luck!
@khaduch thanks!
otmeek sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3481 | @khaduch |http://www.freecodecamp.com/khaduch
and yeah i'm doing some last minute studying and practising
@kevinkiklee thanks have solved the problem
leet-hacks sends brownie points to @kevinkiklee :sparkles: :thumbsup: :sparkles:
api offline
anyone good with recursion here?

var list = [{name: 'meat', value: 123},
{name: 'meat', value: 645},
{name: 'veggies', value: 555},
{name: 'veggies', value: 222},

function recursion(list, name, value){
var obj = {name: name || '' , values: []};


if(e.name === name && e.value !== value){
  obj.name = name;
  obj = recursion(list, e.name, e.value);
return obj;




what i want it to return is objects with values from the list with unique name
so the end goal is {name: 'meat', values: [123,645]}
Ken Haduch
@namsir - are you required to use recursion to solve this? It looks like an ideal place to use .reduce().... ?
i'm allow to use reduce :)
@khaduch can you help pointing to the right direction?
Ken Haduch
@namsir - have you used .reduce() for any other purpose, or is it a new method for you? You can read the MDN documentation on it, of course, and I found this article from the forum to be helpful to me. It took a little while for me to get my head wrapped around how it works.
@khaduch thanks i'll give it a read
namsir sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3482 | @khaduch |http://www.freecodecamp.com/khaduch
Kevin K. Lee
i agree with ken. recursion is not the best for this. also, imo, i think using filter would be the best for what you want to achieve. it is def solvable with reduce though.
also, take the time to master reduce. it's the swiss army knife. there are so many things you can do with it. any time you have to derive a value from a collection, or transform a collection into a different structure, def look at reduce first.
@kevinkiklee going to master reduce :D
I am trying to toggle from F to C in the weather APP but i am not able to
I tried boolean too but again it did not happen.
WHat am i doing wrong here.
Please tell
@BuntyBru because the variable c is initialized with 0 directly before the if, it will always be 0 when reaching the if statement which tests it. Each call to the event handler will create a new variable c. It does not persist over multiple calls.
if i declare "c" outside then some other problem comes up
Christopher Susi
@heroiczero thank you so much for the advice. I’ll check those out soon.
chrisandsuch sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 2038 | @heroiczero |http://www.freecodecamp.com/heroiczero
Stephen James
@BuntyBru Declare a global boolean rather than integer.
var celsius = true;
Then in the function you can do
if (celsius) {
   // change to F
} else {
  // change to C
celsius = !celsius;
@BuntyBru in the if statement for the status: `this.readyState=
this.readyState=4 is the error then
You need == for it to be a condition
Your eventhandler was added twice because the if condition was not right. Therefore your click always executed the function for the change of f/c twice
Stephen James
@alpox :+1: