These are chat archives for FreeCodeCamp/Help

24th
May 2018
Kyle Holm
@thekholm80
May 24 2018 00:19
@aven877 yar
idris
@idris12
May 24 2018 00:57
hi why is it that when i wrap my code in the form tag it doesn't work anymore
form.PNG
form 2.PNG
Stephen James
@sjames1958gm
May 24 2018 01:36
@idris12 Does it appear that the page resets when you click submit or press enter?
@idris12 A form will automatically submit to the backend and reset the page if you don't stop it.
https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
Claudio Restifo
@Marmiz
May 24 2018 04:40

I'll drop it here as well:

anyone knows if in react propTypes I can:

Component.propTypes = {
// test for an array of Objects with a particular shape
  data: PropTypes.arrayOf(
    PropTypes.shape({ title: PropTypes.string, value: PropTypes.number })
  ),
// instead of just an array of objects
  data: PropTypes.arrayOf(PropTypes.object)
};

Unfortunately I'm not leveraging TS here T_T

Kranti Nebhwani
@darkphotonKN
May 24 2018 10:06
guys the top: 20 in css, what is the difference between using just a number like that and top: 20px with px for the number. I see some using px and sometimes without, and if I try it they do different things but I don't know how to search this question online i tried
rosa
@lovelyrosa
May 24 2018 10:34
hi how can I "disable" target1 with jQuery?
$(".target1").prop("disabled",ture);
right?
I don't know what is wrong with the code?
sandeep bhatt
@sandy100_gitlab
May 24 2018 10:39
check the spelling
it must be true
:)
Stephen James
@sjames1958gm
May 24 2018 10:44
@darkphotonKN As far as I can tell top:20 is invalid
Nyle
@nyleusa_gitlab
May 24 2018 11:10
I have a Demo website and I am trying to change the Audio track, but I am confused why there is .mp3 link and .ogg link? (mp3: "http://www.jplayer.org/audio/mp3/Miaow-03-Lentement.mp3",
oga: "http://www.jplayer.org/audio/ogg/Miaow-02-Hidden.ogg",), please help.
yonghuiliao
@LYH1998
May 24 2018 11:21
how to get a image into it
Norvin Burrus
@ndburrus
May 24 2018 11:48
@lovelyrosa this may be useful: :sparkles:
Prateek Kapoor
@PK_TheScientist_twitter
May 24 2018 12:22
Can somebody help me with the flash messages !!!
I have to click the register button twice to see the flash message
How to fix this bug any help??
Norvin Burrus
@ndburrus
May 24 2018 12:33
@PK_TheScientist_twitter this may be helpful: :sparkles:
Kingsley
@Kingwindie
May 24 2018 15:56
some help me out,i'm a little brain fried
(changeBg === "black") ? changeBg("white", "black"): changeBg("black", "white");
changeBg("black", "white");
function changeBg(background, textColor) {
div.style.backgroundColor = background;
  div.style.color = textColor;
}
does above blocks of code mean,if changeBg is black,the background should change to white?
this is the argument
changeBg("black", "white");
Kyle Holm
@thekholm80
May 24 2018 16:30
if changeBg is a function, when will changeBg === "black" ever be true?
Kingsley
@Kingwindie
May 24 2018 16:37
i chnaged it to the argument background,i think it works fine,now i need to go figure out what recursion is. thanks @thekholm80
CamperBot
@camperbot
May 24 2018 16:37
kingwindie sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1793 | @thekholm80 |http://www.freecodecamp.org/thekholm80
Kyle Holm
@thekholm80
May 24 2018 16:37
@Kingwindie recursion is pretty easy if you know recursion
but to know recursion first you have to learn recursion
Kingsley
@Kingwindie
May 24 2018 16:38
@thekholm80 i have never heard of it
Kyle Holm
@thekholm80
May 24 2018 16:38
i'm making a joke lol
recursion isn't bad, though. it's just calling a function from inside itself
Kingsley
@Kingwindie
May 24 2018 16:38
oh ok lol?
oh the console is saying there is too much recursion,i'll look at my code again
Kyle Holm
@thekholm80
May 24 2018 16:39
const recursiveFuction = () => {
  recursiveFuction();  // don't do this, this specific example will create an infinite loop
}
Kingsley
@Kingwindie
May 24 2018 16:43
i don't fully understand your code but point taken,don't call a function inside itself
Kyle Holm
@thekholm80
May 24 2018 16:44
oh no, calling a function inside itself is what recursion is. it's very useful, but my example is just to illustrate calling a function inside itself. you have to have some kind of 'exit condition' or it will run forever
that being said, it's a lot to wrap your head around and generally gives me a headache to try to think about
Kingsley
@Kingwindie
May 24 2018 16:46
ok
Gulsvi
@gulsvi
May 24 2018 16:47
Calculating the nth number of a fibonacci sequence is a common starting point for learning about recursion:
function nthFibonacci(n) {
  if (n <= 1) return 1;

  return nthFibonacci(n - 1) + nthFibonacci(n - 2);
}

nthFibonacci(9) // 55
Kyle Holm
@thekholm80
May 24 2018 16:47
oh, that is a good use-case
i've only ever used recursion for traversing binary trees, and i try to avoid binary trees because they make my head hurt
Gulsvi
@gulsvi
May 24 2018 16:49
lol, I'm going through that now. Recursion makes it so much easier, but a catch 22 because recursion is not easy lol
Kingsley
@Kingwindie
May 24 2018 16:49
lol i'm not as advanced as you are, i honestly don't know what all that stuff means
Kyle Holm
@thekholm80
May 24 2018 16:50
you'll get there. we all start at the beginning
Kingsley
@Kingwindie
May 24 2018 16:50
but i've fixed the code,it's not showing any errors in the browser console
function updateBg(background, textColor) {

  div.style.backgroundColor = background;
  div.style.color = textColor;
}

function changeBg(background, textColor) {


  (background === "black") ? updateBg("white", "black"): updateBg("black", "white");

}
changeBg("black", "green");
Stephen James
@sjames1958gm
May 24 2018 17:01
@Kingwindie You should be use textColor in your function, not "white" or "black"
Also, pass the element in to make it more generic
Kingsley
@Kingwindie
May 24 2018 17:04
use textColor in updateBg?,which function?
@sjames1958gm
Stephen James
@sjames1958gm
May 24 2018 17:06
@Kingwindie changeBg (where you aren't using it), I guess it depends on what you are trying to do.
Kingsley
@Kingwindie
May 24 2018 17:08
changeBg("black", "green");
i'm using this line to test the function,to see if the background will change based on what i type in @sjames1958gm
Stephen James
@sjames1958gm
May 24 2018 17:08
@Kingwindie What do you expect the rsult of calling this function to be?
Kingsley
@Kingwindie
May 24 2018 17:09
to change the background color of a div
Stephen James
@sjames1958gm
May 24 2018 17:09
@Kingwindie What is the second parameter for?
Kingsley
@Kingwindie
May 24 2018 17:09
the text color in the div
but i'm not testing it
Stephen James
@sjames1958gm
May 24 2018 17:10
@Kingwindie Ah ok.
That is the part that confused me
Kingsley
@Kingwindie
May 24 2018 17:12
lol ok, i was just changing the background color based on background passed into the function,to be either black or white,the text,is just for readability
if you remove the second argument " green" ,it still works,i don't know why but i guess it's because i'm not testing it here
 (background === "black") ? updateBg("white", "black"): updateBg("black", "white");
Stephen James
@sjames1958gm
May 24 2018 17:18
@Kingwindie Yeah, since you aren't using it, it doesn't matter
Norvin Burrus
@ndburrus
May 24 2018 17:42
@EvaChuks you may enjoy this: :sparkles: