These are chat archives for FreeCodeCamp/Help

24th
Jan 2019
Christopher McCormack
@cmccormack
Jan 24 00:00
@glitz20 you should really try to troubleshoot this on your own for a bit instead of asking for help at each step, the answers have been very similar - you're having issues with async function, if you need to brush up on them I recommend doing so
in this case you don't have a callback function for your second .then, you just threw the axios call into it
nsonhouse
@nsonhouse
Jan 24 00:25
Hello all. Can any one offer a suggestion on how to click a button that will initiate a route to another page. I'm confused about where the function would exist. All of my routes are in my app.js file. An onclick function would be in another .js file. What is the best way to accomplish this task?
abraham anak agung
@padunk
Jan 24 01:13
@nsonhouse what lib you used? I usually have my function on the button onclick, or using react router, just use Link component
Praveen Saraogi
@saraogipraveen
Jan 24 06:52
anyone learning react ..here? we can learn together
Claudio Restifo
@Marmiz
Jan 24 07:39
@raviloop there are both react veterans and novice as well here. I'm sure you'll find the support you need
alexV
@alexpande
Jan 24 09:43
hi
 //This is a simple set of data relationships
    var links=[
            {source:0,target:3},
            {source:0,target:4},
            {source:0,target:5},
            {source:1,target:3},
            {source:1,target:4},
            {source:1,target:5},
            {source:3,target:6},
            {source:3,target:7},
            {source:3,target:8},
            {source:4,target:6},
            {source:4,target:7},
            {source:4,target:8},
            {source:7,target:9},
            {source:7,target:10},
            {source:7,target:11},
         ];

       //Result after data grouping
       var result=[[0,1],[3,4,5],[6,7,8],[9,10,11]]
How to write a conversion method
tundeiness
@tundeiness
Jan 24 10:23
@raviloop sure PM me lets see what we can do.
Claudio Restifo
@Marmiz
Jan 24 10:33
@alexpande what's the logic for grouping?
Altin Rrahmani
@DevKosov
Jan 24 10:38
function ViewPort(){
    var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
    var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
    var atan = Math.atan2(h / w);
    var angle = 90 - atan;
    alert(angle);
}
anyone knows why my alert of angle is NaN ?
May Kittens Devour Your Soul
@diomed
Jan 24 10:41
:octocat:
Altin Rrahmani
@DevKosov
Jan 24 10:41
broo @diomed is still alive
abraham anak agung
@padunk
Jan 24 10:46
@DevKosov maybe Math.atan2(h, w) ?
Altin Rrahmani
@DevKosov
Jan 24 10:47
@padunk muchas gracias ty
umasharma11
@umasharma11
Jan 24 10:49
hi
i am trying to learn js
const person = {
    name: 'Uma',
    age: 55,

    greet: () => {

        console.log('Hi, i am ' + this.name);
    }
};

person.greet();
when i run ,,
i get this
Hi, i am undefined
umasharma11
@umasharma11
Jan 24 10:54
why it is undefined and does not show my name
abraham anak agung
@padunk
Jan 24 10:55
@umasharma11 fat arrow function doesn't have its own this. so use function expression instead of arrow function
umasharma11
@umasharma11
Jan 24 10:58
got it
Thanks @padunk
abraham anak agung
@padunk
Jan 24 11:01
@umasharma11 :thumbsup:
Andrew Zamora
@AndrewZamora
Jan 24 11:38
Sorry if I'm not asking this in the right way. Does anyone know how I can copy the value on this.state.timer instead of making a reference to it?
constructor(props) {
    super(props)
    this.state = {
      breakLength: 5,
      sessionLength: 20,
      interval: '',
      session: true,
      break: false,
      timer: 10
    };
  }
  countDown = () => {
    let timeLeft = this.state.timer
    console.log(timeLeft)
    this.setState(prevState => ({
      timer: prevState.timer - 1
    }))
  }
Praveen Saraogi
@saraogipraveen
Jan 24 11:53
@AndrewZamora where you want to copy
Andrew Zamora
@AndrewZamora
Jan 24 11:57
let timeLeft = this.state.timer
@raviloop I'm trying to store the value of this.state.timer in a variable
@raviloop I think what I'm doing right now is just referencing it
Praveen Saraogi
@saraogipraveen
Jan 24 12:11
@AndrewZamora i think there is no problem with that
value is getting copied to timeLeft
Andrew Zamora
@AndrewZamora
Jan 24 12:12
oh ok cool
@raviloop thanks
SaintoftheGallows
@SaintoftheGallows
Jan 24 22:00
```python
print('Discounts on 4,10, and 15, at %20, %30, %40 off respectively')
#ask purchase amount in shirts


shirt=int(input('How many T-Shirts will you be purchasing today?'))
#define price

#define cost of shirts



#find discount
if   shirt >= 4:
     print('20%Off!')

elif shirt >= 10:
     print('30%Off!')

else:
     shirt >= 15
     print('40%Off!')








print('Your discount is $',format(shirt,'.2f'),sep.'')
when I type 11 as the input, why do I get 20%?
I should get 30%
Jason Luboff
@JLuboff
Jan 24 22:03
Becuase 11 is greeater than 4
Order of operations
The first expression to evaluate to true, is the one that is used
SaintoftheGallows
@SaintoftheGallows
Jan 24 22:08
k
Thanks!