These are chat archives for FreeCodeCamp/HelpJavaScript

18th
Mar 2018
FlashHero
@FlashHero
Mar 18 2018 18:57
scrollAbout(){
var scroll = setTimeout(() => {
      scrollAbout();
    }, 1);
}
this isn't working with reactjs
Stephen James
@sjames1958gm
Mar 18 2018 19:03
@FlashHero What do you expect that todo?
FlashHero
@FlashHero
Mar 18 2018 19:04
@sjames1958gm recursion call scrollAbout again and again
it says Cannot read property 'scrollAbout' of undefined
Dardan Demiri
@dardandmr
Mar 18 2018 19:07
function scrollAbout(){
var scroll = setTimeout(() => {
      scrollAbout();
    }, 1);
}
u
@FlashHero
FlashHero
@FlashHero
Mar 18 2018 19:10
@dardandmr It gives me error I don't think you can have the word function in react
Stephen James
@sjames1958gm
Mar 18 2018 20:03
@FlashHero I bet the error is where you are calling the function - not here.
You are going to create an infinite loop that does nothing every 1 msec?
Matej Bošnjak
@mbosnjak01
Mar 18 2018 20:06
Better make an infinite loop of a function that generates all possible RGB / HEX colors on your screen
FlashHero
@FlashHero
Mar 18 2018 20:06
@sjames1958gm no I'm making a smooth auto scrolling effect
Matej Bošnjak
@mbosnjak01
Mar 18 2018 20:06
:(
FlashHero
@FlashHero
Mar 18 2018 20:07
scrollAbout() {
    var current = 0;
    var incrementScroll = 20;
    var finish = 400;
    var scroll = setTimeout(() => {
      scrollAbout();
    }, 1);
    current = current + incrementScroll;
    window.scrollTo(0, current);
    if (current >= finish) {
      clearTimeout(scroll);
    }
  }
@sjames1958gm
@mbosnjak01 lol :smile:
@sjames1958gm it scrolls once and it stops and gives me error
Stephen James
@sjames1958gm
Mar 18 2018 20:09
It might be clearer if you just don't create the timer when current >= finish.
@FlashHero You need this.scrollAbout if you are in a class function - assuming react
Matej Bošnjak
@mbosnjak01
Mar 18 2018 20:10
@FlashHero it's really easy ... crashed my laptop twice
XD
FlashHero
@FlashHero
Mar 18 2018 20:12
@sjames1958gm this.scrollAbout() ?
@mbosnjak01 loops are danger zone category in programming lol
Stephen James
@sjames1958gm
Mar 18 2018 20:17
@FlashHero yes, inside the setTimeout
Tiago Correia
@tiagocorreiaalmeida
Mar 18 2018 20:18
https://music-review.herokuapp.com/ what do you guys think?
FlashHero
@FlashHero
Mar 18 2018 20:18
@sjames1958gm it doesn't work
@tiagocorreiaalmeida it's sick :fire:
Tiago Correia
@tiagocorreiaalmeida
Mar 18 2018 20:21
thanks @FlashHero
CamperBot
@camperbot
Mar 18 2018 20:21
tiagocorreiaalmeida sends brownie points to @flashhero :sparkles: :thumbsup: :sparkles:
:cookie: 323 | @flashhero |http://www.freecodecamp.org/flashhero
Stephen James
@sjames1958gm
Mar 18 2018 20:21
@FlashHero Are you getting the same error?
@FlashHero You are resetting all the values on each call.
FlashHero
@FlashHero
Mar 18 2018 20:24
@sjames1958gm yeah that's what I thought, so I would have to declare some variables in the constructor
Stephen James
@sjames1958gm
Mar 18 2018 20:24
scrollAbout(curr) {
    var current = curr | 0;
    var incrementScroll = 20;
    var finish = 400;
    current = current + incrementScroll;
    window.scrollTo(0, current);
    if (current < finish) {
      setTimeout(() => {
        this.scrollAbout(current);
      }, 1);
    }
  }
Tiago Correia
@tiagocorreiaalmeida
Mar 18 2018 20:24
so @sjames1958gm some free time for codefights today?eheh
Stephen James
@sjames1958gm
Mar 18 2018 20:24
@tiagocorreiaalmeida sure
Tiago Correia
@tiagocorreiaalmeida
Mar 18 2018 20:25
and you @AdelMahjoub ?
Adel
@AdelMahjoub
Mar 18 2018 20:29
@tiagocorreiaalmeida working as expected
Tiago Correia
@tiagocorreiaalmeida
Mar 18 2018 20:29
I mean are you into a fight ?:D
with the keyboard
and fight your inner brain cells
Tiago Correia
@tiagocorreiaalmeida
Mar 18 2018 20:39
I guess its a 1vs2 @sjames1958gm
1vs1*
Stephen James
@sjames1958gm
Mar 18 2018 20:39
@tiagocorreiaalmeida lol I was wondering who was 1 and who was 2 :)
FlashHero
@FlashHero
Mar 18 2018 20:42
@sjames1958gm thanks
CamperBot
@camperbot
Mar 18 2018 20:42
flashhero sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9112 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Tiago Correia
@tiagocorreiaalmeida
Mar 18 2018 20:45
the firstone is somehow breaking my brain in half and its basic math's xd
Tiago Correia
@tiagocorreiaalmeida
Mar 18 2018 20:53
the first One I had to check stackoverflow and still I literally used their code to reduce it
Stephen James
@sjames1958gm
Mar 18 2018 20:56
So you couldn't solve it and still got points
Tiago Correia
@tiagocorreiaalmeida
Mar 18 2018 20:56
yeah failed 1 of the hidden tests..
got 60 for the others
nice solution on the first one I couldnt get my self there
Stephen James
@sjames1958gm
Mar 18 2018 20:57
@tiagocorreiaalmeida I didn't think of sorting the array
Brian
@BrianCodes33
Mar 18 2018 21:31
@sjames1958gm can you get to 100k brownie points by lifes end?
Stephen James
@sjames1958gm
Mar 18 2018 21:32
@BrianCodes33 I doubt it :)
Brian
@BrianCodes33
Mar 18 2018 21:33
you’re in the brownie points hall of fame
Stephen James
@sjames1958gm
Mar 18 2018 22:01
@BrianCodes33 Yeah. Shooting for 10k, but 100k that is pretty far away