These are chat archives for FreeCodeCamp/HelpFrontEnd

16th
Apr 2018
Fonterismo
@Fonterismo
Apr 16 2018 00:04
that works for the head but not the lines
Moisés Man
@moigithub
Apr 16 2018 00:06
isnt the same thing ? :)
u already have an scale on size variable
the only thing u need to figure out is what value/argument to modify...
line(xPosition, yPosition + 5, xPosition, yPosition + 20); //body
what would happen IF u modify that +20
example line(xPosition, yPosition + 5, xPosition, yPosition + 120); //body
Fonterismo
@Fonterismo
Apr 16 2018 00:09
ok
my variable name size is the same as a function already...
Fonterismo
@Fonterismo
Apr 16 2018 00:16
void setup()
{
  size(500,500);
  float sizePosition = 1;
  for(int yCounter = 40; yCounter < 500; yCounter *= 2.1)
  {
    drawStickMan(50, yCounter, sizePosition);
    sizePosition *= 1.5;
    for(int xCounter = 50; xCounter < 500; xCounter += 50)
    {
      drawStickMan(xCounter, yCounter, sizePosition);
    }
  }
}

void drawStickMan(float xPosition, float yPosition, float size1)
{
  ellipse(xPosition, yPosition, 10 * size1, 10 * size1); //head
  line(xPosition, yPosition + 5 * size1, xPosition, yPosition + 20 * size1); //body
  line(xPosition - 7 * size1, yPosition +12 * size1, xPosition + 7 * size1, yPosition + 12 * size1); //arms
  line(xPosition, yPosition + 20 * size1, xPosition - 5 * size1, yPosition + 30 * size1); //left leg
  line(xPosition, yPosition + 20 * size1, xPosition + 5 * size1, yPosition + 30 * size1); //right leg
}
Capture.PNG
why is it doing that...
Teo
@todorare
Apr 16 2018 00:19
The line works by connecting two points
So, you just need to change one point
Fonterismo
@Fonterismo
Apr 16 2018 00:19
the lines are finished
something is looping the drawing in the first column for some reason
but not the other columns
Teo
@todorare
Apr 16 2018 00:22
Maybe this line
drawStickMan(50, yCounter, sizePosition);
Fonterismo
@Fonterismo
Apr 16 2018 00:26
damn thats not supposed to be there
genius detective work
well done
thx
Teo
@todorare
Apr 16 2018 00:27
No problem
Fonterismo
@Fonterismo
Apr 16 2018 00:35
now i cant do the width between the rows properly
head overlaps 1st row
of legs
Fonterismo
@Fonterismo
Apr 16 2018 00:48
done.
that was a bitch
Fonterismo
@Fonterismo
Apr 16 2018 01:45
fuck these problems
stuck on a new one
Dhaval Vira
@dhavalveera
Apr 16 2018 01:51
what is that
and don't use Abusive Words here
Fonterismo
@Fonterismo
Apr 16 2018 01:54
Capture.PNG
i dont have a clue rn
Tom
@moT01
Apr 16 2018 01:59
getting it figured out? @Fonterismo
Fonterismo
@Fonterismo
Apr 16 2018 02:01
nope
Tom
@moT01
Apr 16 2018 02:02
do you have any ideas?
Fonterismo
@Fonterismo
Apr 16 2018 02:02
nope
Moisés Man
@moigithub
Apr 16 2018 02:06
similar to fibonacci
Fonterismo
@Fonterismo
Apr 16 2018 02:10
i still dont know how to do it
Fonterismo
@Fonterismo
Apr 16 2018 02:40
pls
Tom
@moT01
Apr 16 2018 02:48
have you got anywhere?
Fonterismo
@Fonterismo
Apr 16 2018 02:49
no lol
i literally dont know what to do
Tom
@moT01
Apr 16 2018 02:49
what did you try
Fonterismo
@Fonterismo
Apr 16 2018 02:49
i dont know how
Tom
@moT01
Apr 16 2018 02:50
well, what are your abilities
can you make a function?
Fonterismo
@Fonterismo
Apr 16 2018 02:51
yea
Tom
@moT01
Apr 16 2018 02:51
fcc has some javascript challenges that would teach you enough to accomplish this i think
Fonterismo
@Fonterismo
Apr 16 2018 02:51
i dont know the logic
Tom
@moT01
Apr 16 2018 02:51
did you go through those at all
Fonterismo
@Fonterismo
Apr 16 2018 02:51
i mean i know the logic but i dont know how to implement
i know how to code idk how to solve the logic problem
Tom
@moT01
Apr 16 2018 02:52
well, you could start with if (n<=3) {return 1}
Claudio Restifo
@Marmiz
Apr 16 2018 02:57

i mean i know the logic but i dont know how to implement

have you tried pseudo-coding it? Means writing down the function in human language to fix the logic..
then convert it to actual code

Fonterismo
@Fonterismo
Apr 16 2018 03:34
i got nothing
Fonterismo
@Fonterismo
Apr 16 2018 05:01

void setup()
{
theSequence(1);
println(theSequence(5));
}

int theSequence(int n)
{
if(n == 1 || n == 2 || n == 3)
{
return 1;
}
else
{
return (theSequence(n-1) + theSequence(n-2) + theSequence(n-3));
}
}

mustimuu
@mustimuu
Apr 16 2018 05:31

Hello guys !

Can someone explain me the difference between wordpress, drupal and joomla please ?

check out this for Difference between Wordpress, Drupal & Joomla
coderNewby
@coderNewby
Apr 16 2018 06:28
@darrenfj check PM thanks
CamperBot
@camperbot
Apr 16 2018 06:28
codernewby sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2464 | @darrenfj |http://www.freecodecamp.org/darrenfj
shameem fairooz
@sfshameem5
Apr 16 2018 06:32
Hi guys I'm having a problem with a test case in Intermmediate Algorithmic Challenges.
Can anyone help me out ?
Markus Kiili
@Masd925
Apr 16 2018 06:36
@sfshameem5 Sure. What have you got so far?
shameem fairooz
@sfshameem5
Apr 16 2018 06:40
I've nearly completed the challenge except for one test case.
Here's the code
function sumFibs(num) {
    // a holder for fibonacci numbers. 
    var fibonacci = [];
    // fibonacci first and second numbers. 
    var first = 1, second = 1, third = 0;


    for (var i = 0; i < num; i++) {
        fibonacci.push(first + second);
        second = fibonacci[i]; 
        first = second - first;
        if (fibonacci[i] >= num) {
            fibonacci.pop();
            break;
        }
    }

    // add the starting numbers to fibonacci array. 
    fibonacci.unshift(1, 1);

    var counter = 0;

    for (var i = 0; i < fibonacci.length; i++) {
        if (fibonacci[i] % 2 !== 0) {
            counter += fibonacci[i];
        }
    }

    // console.log(counter);

    return counter;

}

sumFibs(75024);
Markus Kiili
@Masd925
Apr 16 2018 06:43
@sfshameem5 That for loop condition doesn't make much sense i < num. That num is an upper limit for the fibos, not the amount of fibos.
A while loop that generates fibos as long as they are <=num would be much simpler.
shameem fairooz
@sfshameem5
Apr 16 2018 06:44
I've made that test case to pass.
I pop the last element if num is even.
Here's the final code.
```
function sumFibs(num) {
    // a holder for fibonacci numbers. 
    var fibonacci = [];
    // fibonacci first and second numbers. 
    var first = 1, second = 1, third = 0;


    for (var i = 0; i < num; i++) {
        fibonacci.push(first + second);
        second = fibonacci[i]; 
        first = second - first;
        if (fibonacci[i] >= num) {
            // if num is even remove the last elemnt. 
            if (num % 2 === 0) {
                fibonacci.pop();
            }
            break;
        }
    }

    // add the starting numbers to fibonacci array. 
    fibonacci.unshift(1, 1);

    var counter = 0;

    for (var i = 0; i < fibonacci.length; i++) {
        if (fibonacci[i] % 2 === 1) {
            counter += fibonacci[i];
            // console.log(counter);
        }
    }

    // console.log(counter);

    return counter;

}

sumFibs(1000);
And it works!
Markus Kiili
@Masd925
Apr 16 2018 06:46
@sfshameem5 Just saying that that for loop does much extra work and is hard to read and understand.
shameem fairooz
@sfshameem5
Apr 16 2018 06:46
@Masd925 Okay then. I'll use a while loop instead.
Markus Kiili
@Masd925
Apr 16 2018 06:49
@sfshameem5 When you have these variables defined var first = 1, second = 1, third = 0;, you could just generate the fibos with a loop and calculate the sum without using any array.
shameem fairooz
@sfshameem5
Apr 16 2018 06:49
Here's the final solution, and it works using a while loop
@Masd925 That seems a bit more complex. I've been struggling with this problem for more than a day now.
function sumFibs(num) {
    // a holder for fibonacci numbers. 
    var fibonacci = [];
    // fibonacci first and second numbers. 
    var first = 1, second = 1, third = 0;


    // for (var i = 0; i < num; i++) {
    //     fibonacci.push(first + second);
    //     second = fibonacci[i]; 
    //     first = second - first;
    //     if (fibonacci[i] >= num) {
    //         // if num is even remove the last elemnt. 
    //         if (num % 2 === 0) {
    //             fibonacci.pop();
    //         }
    //         break;
    //     }
    // }

    var i = 0;

    while (i <= num) {
        fibonacci.push(first + second);
        second = fibonacci[i]; 
        first = second - first;
        if (fibonacci[i] >= num) {
            // if num is even remove the last elemnt. 
            if (num % 2 === 0) {
                fibonacci.pop();
            }
            break;
        }
        i++;
    }


    // add the starting numbers to fibonacci array. 
    fibonacci.unshift(1, 1);

    var counter = 0;

    for (var i = 0; i < fibonacci.length; i++) {
        if (fibonacci[i] % 2 === 1) {
            counter += fibonacci[i];
            // console.log(counter);
        }
    }

    // console.log(counter);

    return counter;

}

sumFibs(4000000);
@Masd925 Thanks for the help!
CamperBot
@camperbot
Apr 16 2018 06:50
sfshameem5 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4779 | @masd925 |http://www.freecodecamp.org/masd925
Markus Kiili
@Masd925
Apr 16 2018 06:52
@sfshameem5 Would you like to see a simple solution without an array?
shameem fairooz
@sfshameem5
Apr 16 2018 06:52
@Masd925 Or shall I try first ? Would you be on?
Markus Kiili
@Masd925
Apr 16 2018 06:52
@sfshameem5 You should try first, yes.
shameem fairooz
@sfshameem5
Apr 16 2018 06:56
@Masd925 I'm stuck. Can you show me the solution instead?
Markus Kiili
@Masd925
Apr 16 2018 06:57
@sfshameem5
function sumFibs(num) {
  var first = 1;
  var second = 1;
  var sum = 2;
  while (first+second<=num) {
    var third = first+second;
    if (third%2!==0) sum += third;
    first = second;
    second = third;
  }
  return sum;
}
shameem fairooz
@sfshameem5
Apr 16 2018 06:58
@Masd925 How long have you been programming ?
Markus Kiili
@Masd925
Apr 16 2018 06:58
@sfshameem5 About 4 and half years.
shameem fairooz
@sfshameem5
Apr 16 2018 06:58
@Masd925 Self-taught, or pursued a cs degree ?
Markus Kiili
@Masd925
Apr 16 2018 06:59
@sfshameem5 I have a bachelors degree that was mostly software development.
shameem fairooz
@sfshameem5
Apr 16 2018 06:59
@Masd925 Ah. Your solution seems so efficient. I dropped a few months back.
@Masd925 I felt like it was I was able to learn all what they taught on my own, and they had no answers for my questions.
@Masd925 So I thought of learning on my own using fcc and teamtreehouse, find a job and pursue a degree on cs later on .
Markus Kiili
@Masd925
Apr 16 2018 07:02
@sfshameem5 That sounds fine.
shameem fairooz
@sfshameem5
Apr 16 2018 07:02
@Masd925 Thanks, for the help. Back to challenges!!!
CamperBot
@camperbot
Apr 16 2018 07:02
sfshameem5 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
api offline
dryyyyy
@dryyyyy
Apr 16 2018 07:40
Hi everyone! I need an advice on how to make this log: foo, bar, buz in console. Here is the code: https://jsfiddle.net/senufp8a/62/
kirbyedy
@kirbyedy
Apr 16 2018 08:03
I dont understand the question
Screen Shot 2018-04-16 at 11.04.03.png
dryyyyy
@dryyyyy
Apr 16 2018 08:24
@kirbyedy It does not log 'buz'
what is the way to see all three?
Aditya
@ezioda004
Apr 16 2018 08:40
@dryyyyy Like this?
foo().then(res =>
        res ? console.log("bar") : false)
   .then(res => 
       "bar" ? console.log("buz") : false);
dryyyyy
@dryyyyy
Apr 16 2018 09:07
@ezioda004 That's great, but is there a way to leave the condition where it was?
Stephen James
@sjames1958gm
Apr 16 2018 10:23
@dryyyyy You can use async/await
async function test() {
   if (await foo().then((res) => {console.log("bar"); return Promise.resolve(res);}) {
      console.log("buz");
  }
}
I believe you have to re-resolve a promise to get the await to work.
I am still iffy on async/await
akte1991
@akte1991
Apr 16 2018 11:08
hello, have anyone of you ever read a w3c specification (html5 for example)
or it is a waste of time? :P
Claudio Restifo
@Marmiz
Apr 16 2018 11:09

@sjames1958gm no kidding I did a similar thing to you this morning.
This is wrong:

const response = await somePromise().then(response => response)

since the first response we get from the promise is the state change (resolving or pending, i don't remember)

What I did was spilt up the awaits:

const response = await somePromise();
const data = await response.theMethodToextractDataFromResponse();
console.log(data)
akte1991
@akte1991
Apr 16 2018 11:10
and another question: do you think caring for a good outline is worth the time and practical? :P or belonging to old and not in use anymore
Markus Kiili
@Masd925
Apr 16 2018 11:10
@akte1991 Reading through it is a waste of time imo, but sometimes when you need exact info about some subject, it can be a valuable reference.
akte1991
@akte1991
Apr 16 2018 11:12
yeah, true, thx Markus
Markus Kiili
@Masd925
Apr 16 2018 11:21
@akte1991 What do you exactly mean by a good outline?
Amit Patel
@AmitP88
Apr 16 2018 11:35
hey guys, I need a little advice if it's ok. I work at a lab in a factory that produces orange juice concentrates. I've been there for a little over 2 years now, and it's a seasonal job (meaning that the plant shuts down for about a few months during the summer, so they have us go on unemployment during that time). This season, they'll be shutting down sometime next month (maybe towards the end of next month) and will be down for about 5 months (hopefully). I am completely sick of my job at this point and I don't think I can handle another season. I was thinking of taking a chance and just commiting myself fully to finishing freecodecamp and doing all the nonprofit projects so that I can be ready for a dev job in January 2019. I would be on unemployment for 6 months (max time it lasts), then I might have to dig into my savings a bit for December and January. I would start applying in January aggressively. I have a linkedin network of over 7k, and I have savings that will last me up to maybe 6-7 months. I was thinking of either doing this or just getting another lab job with hopefully a better work/life balance. Do you think it would be a good idea to just take the rest of the year to learn to code fulltime? or should I look for another lab job instead? (I definitely do not intend to go back to my job once it starts up again later this year)
also, by the end of next month (by the time they shut down), I would have completely all the front end projects on freecodecamp
Markus Kiili
@Masd925
Apr 16 2018 11:42
@AmitP88 Have you applied for any jobs yet? It would help a lot with such considerations, if you knew if you are close to landing a job or not with your current background and portfolio.
Amit Patel
@AmitP88
Apr 16 2018 11:43
@Masd925 I applied to a few jobs before (around 20) and didn't get a single interview. However, my skillset is only html, css, javascript, responsive design for now. This year I want to complete freecodecamp so I can have MERN stack in my skillset
I'm also not doing good in my job, so I'm not going back next season. I either have to commit myself fully and take the plunge into coding fulltime while on unemployment or look for another lab job before they start up again
habibaatify
@habibatify_twitter
Apr 16 2018 11:46
Capture.PNG
what is wrong in that code?
Amit Patel
@AmitP88
Apr 16 2018 11:47
@habibatify_twitter is that a test for me? lol
@habibatify_twitter hatValue is showing a value of 'cleats' which is way off. seems to be an issue with using JSON format with the variables after the object
I haven't gotten to that algorithm yet
my javascript is still kind of weak, but i'm working on it slowly
Fabien SHAN
@X140hu4
Apr 16 2018 11:53
@habibatify_twitter First test that does not pass: The value of hatValue should be "ballcap"
Markus Kiili
@Masd925
Apr 16 2018 11:54
@habibatify_twitter I think it should be like var hatValue = testObj.hat; etc
mstellaluna
@mstellaluna
Apr 16 2018 11:54
@habibatify_twitter your not accessing the values with the key names. the key is hat but you are using hatValue
Amit Patel
@AmitP88
Apr 16 2018 11:54
@Masd925 ugh, of course. I should've got that :(
mstellaluna
@mstellaluna
Apr 16 2018 11:56
@AmitP88 if you want, I have a large list of remote job boards I can send to you via PM
Amit Patel
@AmitP88
Apr 16 2018 11:56
@mstellaluna that would be great :)
mstellaluna
@mstellaluna
Apr 16 2018 11:57
sending u a pm
Amit Patel
@AmitP88
Apr 16 2018 11:57
I still don't know if I should give up my job though to code full time. I really want to get good at this, but it is a big risk
mstellaluna
@mstellaluna
Apr 16 2018 11:59
the jobs board I have are for the USA
Ayobami
@purpose50
Apr 16 2018 12:10
@habibatify_twitter testObj does not have a property 'hatValue' or 'shirtValue', you should be referencing testObj.hat not testObj.hatValue, the same thing applies to shirt, you should be referencing testObj.shirt not testObj.shirtValue
Markus Kiili
@Masd925
Apr 16 2018 12:11
@AmitP88 Your skillset at the moment is limited, so I would not advice you to quit your current field of work. Another lab job and learning part time sound the best.
Amit Patel
@AmitP88
Apr 16 2018 12:12
@Masd925 ah ok, that makes sense. Besides, I'll still have a few months to study fulltime regardless
@Masd925 thanks Markus :)
CamperBot
@camperbot
Apr 16 2018 12:12
amitp88 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4780 | @masd925 |http://www.freecodecamp.org/masd925
Amit Patel
@AmitP88
Apr 16 2018 12:20
besides, it's kind of scary thinking how long it would take me to find my first dev job
Kenneth Malicay
@kennethlumalicay
Apr 16 2018 12:56
“If you’re not scared then you’re not taking a chance. If you’re not taking a chance then what the hell are you doing anyway?”
― Ted Mosby
Aiden
@AidenMead
Apr 16 2018 12:57
Hello World
How's everyone today?
Kenneth Malicay
@kennethlumalicay
Apr 16 2018 12:57
I'm not one to talk though, job hunting drains your soul. :)
Luke Pighetti
@lukepighetti
Apr 16 2018 15:03
Hi everyone
I ran into a CORS error and I'm stumped
This is my GET code running in the browser
function getJSON(URL){
  var request = new XMLHttpRequest();
  request.open('GET', URL, true);

  request.onload = function() {
    if (request.status >= 200 && request.status < 400) {
      // Success!
      return JSON.parse(request.responseText);
    } else {
      return null;
    }
  };

  request.onerror = function() {
    return null;
  };

  request.send();
}
This is the error I get Failed to load https://explorer.pigeoncoin.org/ext/summary: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

And this is what happens when I try to use https://cors-anywhere.herokuapp.com/https://explorer.pigeoncoin.org/ext/summary

Missing required request header. Must specify one of: origin,x-requested-with

Nate Mallison
@NJM8
Apr 16 2018 15:14
@lukepighetti Is that your api or someone elses?
Luke Pighetti
@lukepighetti
Apr 16 2018 15:15
It's mine, but I did not write it
Tony Hudson
@ngohungphuc
Apr 16 2018 15:15
I have this problem in ReactJS Each child in an array or iterator should have a unique "key" prop. even though already define key. Am I missing something
switch (input.type) {
      case APP_ENUM.INPUT_TEXT:
        inputField.push(
          <div className="row">
            <div className="col-md-12">
              <div className="form-group" key={input.key}>
                <ACCInput
                  type={input.type}
                  name={input.name}
                  required={input.required}
                  placeholder={input.name}
                />
              </div>
            </div>
          </div>
        );
        break;
}
@lukepighetti you have to turn on cors request in backend
Luke Pighetti
@lukepighetti
Apr 16 2018 15:16
API is served by node/express
I will look into that
I have a hard time understanding why this would be a server side setting and not client side?
Why would that be the standard?
Tony Hudson
@ngohungphuc
Apr 16 2018 15:17
then you have to configure for node server side.
Luke Pighetti
@lukepighetti
Apr 16 2018 15:17
does this mean that no one can access my API?
even though its public and accessible with a browser
Tony Hudson
@ngohungphuc
Apr 16 2018 15:18
is just a warning that you making cross request resource. Mean that url not belong to your web app
take a look at this
Luke Pighetti
@lukepighetti
Apr 16 2018 15:19
does it work across subdomains?
Tony Hudson
@ngohungphuc
Apr 16 2018 15:19
yes
check Simple Usage (Enable All CORS Requests)
Luke Pighetti
@lukepighetti
Apr 16 2018 15:19
actually – here's where I am confused
Tony Hudson
@ngohungphuc
Apr 16 2018 15:20
inbox me

Any chance this problem will be solve. Hope some one can help me

I have this problem in ReactJS Each child in an array or iterator should have a unique "key" prop. even though already define key. Am I missing something

switch (input.type) {
      case APP_ENUM.INPUT_TEXT:
        inputField.push(
          <div className="row">
            <div className="col-md-12">
              <div className="form-group" key={input.key}>
                <ACCInput
                  type={input.type}
                  name={input.name}
                  required={input.required}
                  placeholder={input.name}
                />
              </div>
            </div>
          </div>
        );
        break;
}
Ayobami
@purpose50
Apr 16 2018 15:30
@ngohungphuc I'm just a beginner but I'll like to make a comment anyways, are you sure the keys are unique for every iteration, have you tried console logging the value you initialized to the key prop on each iteration to confirm if they are unique ?
Tony Hudson
@ngohungphuc
Apr 16 2018 15:31
im pretty sure
never mind here is how i fix put key in the outer one div
inputField.push(
          <div className="row" key={input.name}>
            <div className="col-md-12">
              <div className="form-group">
                <ACCInput
                  type={input.type}
                  name={input.name}
                  required={input.required}
                  placeholder={input.name}
                />
              </div>
            </div>
          </div>
        );
@purpose50 still thank for your recommend :D
CamperBot
@camperbot
Apr 16 2018 15:32
ngohungphuc sends brownie points to @purpose50 :sparkles: :thumbsup: :sparkles:
:cookie: 306 | @purpose50 |http://www.freecodecamp.org/purpose50
Tony Hudson
@ngohungphuc
Apr 16 2018 15:32
@camperbot hey what are you doing here LOL
Ayobami
@purpose50
Apr 16 2018 15:38
@ngohungphuc :+1:
Kingsley
@Kingwindie
Apr 16 2018 15:41
is it possible to store image files and display the images in the browser,example ```
var images = [link to image file goes here]"" and then display the images in the browser
Tanmay Halde
@tanmayHalde
Apr 16 2018 15:42
Need feedback on stock market proj. Thanks. https://th-chartstock.herokuapp.com/
Kingsley
@Kingwindie
Apr 16 2018 15:43
var images = [link to image file goes here]
Tony Hudson
@ngohungphuc
Apr 16 2018 15:46
yes you can but what do you want to display ? React, Angular, Vue ?
DerMann97
@DerMann97
Apr 16 2018 15:55
[JAVA] Hello guys ! Can someone help me to understand the left Hand algorithm ( maze solver ) ? Thanks a lot
Tony Hudson
@ngohungphuc
Apr 16 2018 16:17
Code_2018-04-16_23-17-45.png
Hi guys, how can I use input.name as left hand argument ?
hansUno2
@hansUno2
Apr 16 2018 16:24
@ngohungphuc no
Assuming input is a reference to an HTML input element
Tony Hudson
@ngohungphuc
Apr 16 2018 16:25
@hansUno2 so what is your suggest I need to pass name of the input to onChange.call
hansUno2
@hansUno2
Apr 16 2018 16:26
Name is a attribute of an input element
Tony Hudson
@ngohungphuc
Apr 16 2018 16:26
i mean input.name
hansUno2
@hansUno2
Apr 16 2018 16:26
I would suggest using. Input.getAttribute
@ngohungphuc To be honest, im not sure that you can't use input.name
Tony Hudson
@ngohungphuc
Apr 16 2018 16:28
no you cant
hansUno2
@hansUno2
Apr 16 2018 16:29
What i am sure is that if you want to get the value of an input's name attribute, use .getAttribute
Tony Hudson
@ngohungphuc
Apr 16 2018 16:32
Im already have it using input.name
what i need is use that input.name inside onChange
hansUno2
@hansUno2
Apr 16 2018 16:36
If the onchange function is being run on the same input..assuming... Why not use this.name or this.getAttribute()
Tony Hudson
@ngohungphuc
Apr 16 2018 16:37
that what i want to say i cant use this.name => onChange.call
you see the warning i get
hansUno2
@hansUno2
Apr 16 2018 16:38
Well arrow function binding might be the problem
Try using regular function syntax and see if the error occurs
I dont know the context of the code you are working on but that's a common issue when using the this keyword with arrow functions
Tony Hudson
@ngohungphuc
Apr 16 2018 16:40
@hansUno2 will try it now. Thank you
CamperBot
@camperbot
Apr 16 2018 16:40
ngohungphuc sends brownie points to @hansuno2 :sparkles: :thumbsup: :sparkles:
:cookie: 15 | @hansuno2 |http://www.freecodecamp.org/hansuno2
hansUno2
@hansUno2
Apr 16 2018 16:40
Did it work?
Tony Hudson
@ngohungphuc
Apr 16 2018 16:40
just a min
not working
Tony Hudson
@ngohungphuc
Apr 16 2018 16:46
Cannot read property 'setState' of undefined
hansUno2
@hansUno2
Apr 16 2018 16:46
React app?
Tony Hudson
@ngohungphuc
Apr 16 2018 16:47
yes
Ahmedur Rahman Shovon
@arsho
Apr 16 2018 16:47
Hi @ngohungphuc , can you state your problem again? :)
the problem I have is I cant use input.name => onChange.call(this, input.name)
I will get Cannot read property 'setState' of undefined
hansUno2
@hansUno2
Apr 16 2018 16:49
Input.name produces a defined result right?
Tony Hudson
@ngohungphuc
Apr 16 2018 16:49

Yes

Input.name produces a defined result right?

hansUno2
@hansUno2
Apr 16 2018 16:51
And you are calling onchange on that result?
Ahmedur Rahman Shovon
@arsho
Apr 16 2018 16:52
Ow! I am not in context of that codebase. But you may set initial state of the states in constructor?
Tony Hudson
@ngohungphuc
Apr 16 2018 16:52

Correct

And you are calling onchange on that result?

No need to do that, the state is being pass into

Ow! I am not in context of that codebase. But you may set initial state of the states in constructor?

hansUno2
@hansUno2
Apr 16 2018 16:53
Dont know much of react but should onchange be called on an element?
Shouldn't*
Ayobami
@purpose50
Apr 16 2018 16:54
@ngohungphuc , that syntax is wrong. The handler you are passing to onChange is a function definition (using the arrow function syntax).
hansUno2
@hansUno2
Apr 16 2018 16:55
@purpose50 what i was thinking as well
Ayobami
@purpose50
Apr 16 2018 16:55
I am not sure what you are trying to do, but you can try onChange={ () => onChange.call(this, input.name)}
Ayobami
@purpose50
Apr 16 2018 17:04
I just checked the full code now, what I think is right is onChange={() => onChange(input.name)} assuming the imported onChange is a function.
this in a functional component is undefined.
Tony Hudson
@ngohungphuc
Apr 16 2018 17:04
Code_2018-04-17_00-04-42.png
Stephen James
@sjames1958gm
Apr 16 2018 17:14
@ngohungphuc I don't think you can use this inside of functional components.
https://hackernoon.com/react-stateless-functional-components-nine-wins-you-might-have-overlooked-997b0d933dbc
Ayobami
@purpose50
Apr 16 2018 17:22
@ngohungphuc
The onChange function that handles the input element change needs the correct context for it to work since it is referencing this in it.
First thing is the functional component does not have a context to reference this on.
Secondly, you can only call setState in class based component (functional components are actually also known as Stateless Functional Components).
In essence, refactor to a class-based component if you really need the input element to be controlled using the onChange function.
Alwin George
@siliconchild
Apr 16 2018 17:45
if anybody wants help with css let me know
Helio Goncalves
@srlhyo
Apr 16 2018 18:19
hi all. anyone here who uses Vim?
B.Oussama
@0usssama
Apr 16 2018 18:25
hi,
in the quote machine project i don't know why the 1st click is undefined in my array hope someone can help me
this is the codepen link
https://codepen.io/B-oussama/pen/EEBvvQ
Stephen James
@sjames1958gm
Apr 16 2018 18:30
@0usssama console.log(quotesArray[strIndex]); this code is running before the response to the getJSON is returned, so your array is not yet populated
@0usssama All the code accessing quotesArray should be inside the second getJSON callback
B.Oussama
@0usssama
Apr 16 2018 18:34
@sjames1958gm thank you !
CamperBot
@camperbot
Apr 16 2018 18:34
0usssama sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9205 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Mark Kubik
@KUBIX90
Apr 16 2018 18:37
Hi can anyone help with this issue that im having with my website
weirdAnimationGlitch.gif
the transitions flash up on page load and then disappear it's really jarring
relevant info above. Any help would be appreciated, everyone I've asked so far is stumped on it
Aiden
@AidenMead
Apr 16 2018 19:02
@KUBIX90 Your portfolio looks great, I love the design. What browser are you using? I'm in Chrome for MacOS and I don't get any flash of markup on/right before page load at all.
Tiago Correia
@tiagocorreiaalmeida
Apr 16 2018 19:03
same here @KUBIX90
Mark Kubik
@KUBIX90
Apr 16 2018 19:03
@AidenMead Thanks, I'm on firefox, windows 10
CamperBot
@camperbot
Apr 16 2018 19:03
kubix90 sends brownie points to @aidenmead :sparkles: :thumbsup: :sparkles:
:cookie: 333 | @aidenmead |http://www.freecodecamp.org/aidenmead
Tiago Correia
@tiagocorreiaalmeida
Apr 16 2018 19:04
let me try out firefox
are you using prefixs?
Mark Kubik
@KUBIX90
Apr 16 2018 19:04
@tiagocorreiaalmeida This is the problem I'm having, it just seems to be me having this issue. Could just be my computer/browser settings? If so what could it possibly be?
No
Tiago Correia
@tiagocorreiaalmeida
Apr 16 2018 19:04
then its time to try out prefix it
create a new css file
Aiden
@AidenMead
Apr 16 2018 19:05
I'll try safari quick, too.
Tiago Correia
@tiagocorreiaalmeida
Apr 16 2018 19:05
paste your code in and copy the output into the new file and change the file linking to the new one just to test out
Mark Kubik
@KUBIX90
Apr 16 2018 19:06
@tiagocorreiaalmeida cheers, I'll give this a go and report back
Aiden
@AidenMead
Apr 16 2018 19:07
@KUBIX90 I'm actually now getting the issue when I pull it up, interestingly enough.
Mark Kubik
@KUBIX90
Apr 16 2018 19:12
@AidenMead I've had it occasionally happen on chrome as well but its quite random
@tiagocorreiaalmeida Nope, issue still remains with using the prefixer tool
Aiden
@AidenMead
Apr 16 2018 19:17
@KUBIX90 It looks like it's an alert for your Twitch App. It's showing info that normally would show on the web app example as an alert.
Tiago Correia
@tiagocorreiaalmeida
Apr 16 2018 19:18
everything here goes perfectly :\
Aiden
@AidenMead
Apr 16 2018 19:18
Screen Shot 2018-04-16 at 3.16.45 PM.png
There's a still of what's actually alerting on load.
Mark Kubik
@KUBIX90
Apr 16 2018 19:21
@AidenMead I think it's the modals in general, I removed the twitch one and the other one behind just popped up instead
Could it be the keyframes?
Aiden
@AidenMead
Apr 16 2018 19:21
Ahhhhh
That would be the only thing that makes sense, the keyframes.
I didn't realize they all had pop up modals at first, lol.
Aiden
@AidenMead
Apr 16 2018 19:28
What about - and this is just a theory - instead of hiding the modals off screen, they were also set to hidden initially? I'm not sure if that would work, just spitballing.
Mark Kubik
@KUBIX90
Apr 16 2018 19:33
@AidenMead I've tried visibility hidden, and that makes the most of the modal disappear, but the links still show for some reason
the github buttons on the modal
Aiden
@AidenMead
Apr 16 2018 19:43
hmmm
Aiden
@AidenMead
Apr 16 2018 19:48
what about opacity: 0?
Mark Kubik
@KUBIX90
Apr 16 2018 19:54
nope doesn't work
I've seen a hacky potential solution's online but don't really want to use it
Bjorn van de Peut
@bjorno43
Apr 16 2018 19:59
@KUBIX90 I'm not exactly sure what you're trying to do or what library you're using, but if want to completely hide something, I'd try display: none;
Keegan
@Keggatron
Apr 16 2018 21:10

Hi guys, I'm having issues displaying .svg images in my app. Here's the code to the component:

const WeatherGrid = (props) => {

  return (

    <ul className='grid'>

      {props.forecast.list.map((data) => {

      const imgUri = `../../public/images/weather-icons/${data.weather[0].icon}.svg`

        return(
          <li key={data.dt}>
            <img src= {imgUri}/>
          </li>
        )
      })}
    </ul>

  )
}

All it returns are a list of broken images when I run it. I've even tried moving one of the images into my components folder in order to make sure I didn't write in the wrong link

Wadie
@wadie
Apr 16 2018 21:25
hi
anyone around ?
Ashraf Patel
@AshrafPatel
Apr 16 2018 21:39
hey can someone help me with this question reverse string algorithm challenge
function palindrome(str) {
  var a = str.toLowerCase();
  var b = a.split("");
  b.reverse();
  b.join("");
  for (var i = 0; i < str.length; i++)
  {
    if (a[(a.length - i)] == b[i])
    {
      if (i == str.length)
      {
        return true;
      }
    }
  }
  return false;
}

palindrome("eye");
Ken Haduch
@khaduch
Apr 16 2018 21:43
@AshrafPatel - one key to solving this is that you have to strip out anything that is not a letter or number first (that includes spaces) and then working with the string. You can also avoid the use of the for loop by having a cleaned-up copy of the string, then just generating a reversed copy of that string and comparing them with ===.
Ashraf Patel
@AshrafPatel
Apr 16 2018 21:51
```str.replace(" ", [0-9], "*", "/", "\");
str.replace(" ", [0-9], "*", "/", "\");
@khaduch would that work
abe312
@abe312
Apr 16 2018 22:01
@AshrafPatel I think I used regex to strip the string and then str.toLowerCase().split("").reverse().join("")
Ashraf Patel
@AshrafPatel
Apr 16 2018 22:45
function palindrome(str) {
  var regex = /[\s\'\#\/\"\,\/\-\_\.\)\:\|\()\*]/g;
  var a = str.replace(regex, "");
  a = str.toLowerCase();
  var b = a.split("");
  b.reverse();
  b.join("");
  if (a == b)
        return true;
  return false;
}

palindrome("eye");
why is this not working
Teo
@todorare
Apr 16 2018 22:47
Off the top of my head, b.join("") is not actually changing the b variable, but it's just returning the result of join
Try b = b.join("")
Brad
@bradtaniguchi
Apr 16 2018 22:47
@todorare Is correct
Did the challenge require a regex like that tho?
i don't remember off the top of my head :/
Teo
@todorare
Apr 16 2018 22:49
It looks like a very complex emoji
:D
Ken Haduch
@khaduch
Apr 16 2018 22:54
@AshrafPatel - the regular expression could be simplified, but that might be working if you've covered all of the characters. And after the .replace() you are generating a string in a, but then going back to using str.toLowerCase() - using str instead of a. Then after that you have to save the results of your b.reverse() and b.join('') into a variable, which you can use b again.
Lastly, you can chain operations together like var a = str.replace(regex, '').toLowerCase() - so you can have var b = a.split('').reverse().join(''); in the same way, chaining those results together. Actually, you can simplify further by eliminating some of the intermediate variables, for example if (a === a.split('').reverse().join('')) so you don't need to save the reversed string.
Ashraf Patel
@AshrafPatel
Apr 16 2018 22:55
@khaduch what do you know lol i feel stupid now haha
Ken Haduch
@khaduch
Apr 16 2018 22:56
@AshrafPatel - well, it's a learning process. One thing that could be interesting is if you put some console.log statements in and saw the results at intermediate points.
Ashraf Patel
@AshrafPatel
Apr 16 2018 22:58
function palindrome(str) {
  var regex = /[\s\'\#\/\"\,\/\-\_\.\)\:\|\()\*]/g;
  var a = str.replace(regex, "");
  a.toLowerCase();
  alert(a);
  var b = a.split();
  b.reverse();
  b.join();
  alert(b);
  if (a == b) {
    return true;
  }
  else {
   return false; 
  }
}

palindrome("eye");
@khaduch solved it but false is not reading
zootechdrum
@zootechdrum
Apr 16 2018 23:00
hey guys
i am trying to remove both instanaces of dups
Brad
@bradtaniguchi
Apr 16 2018 23:00
@zootechdrum wut
Ken Haduch
@khaduch
Apr 16 2018 23:00
@AshrafPatel - don't forget to save the results of the a.toLowerCase() and b.reverse(), etc - they do not mutate the array in place but return a new array with the action completed.
Teo
@todorare
Apr 16 2018 23:00
@AshrafPatel You need to assign b.join() to b
zootechdrum
@zootechdrum
Apr 16 2018 23:01
i found this code in stack overflow. But can not for the life of me understand it. I don see how h or i can be on different indexes and always result on the same number.
Teo
@todorare
Apr 16 2018 23:01
Like b = b.join();
zootechdrum
@zootechdrum
Apr 16 2018 23:01
var myArr = [1, 2];
var newArr = myArr;


for(var h = 0; h < myArr.length; h++) {
    var curItem = myArr[h];
    var foundCount = 0;
    // search array for item
    for(var i = 0; i < myArr.length; i++) {
        if (myArr[i] == myArr[h])
            foundCount++;
    }
    if(foundCount > 1) {
        // remove repeated item from new array
        for(var j = 0; j < newArr.length; j++) {
            if(newArr[j] == curItem) {                
                newArr.splice(j, 1);
                j = j - 1;
            }
        }            
    }
}

alert(newArr.toString())
Teo
@todorare
Apr 16 2018 23:01
Like @khaduch is saying
Ken Haduch
@khaduch
Apr 16 2018 23:02
@AshrafPatel - see what I did in my note - I added some edits after the original post :point_up: April 16, 2018 6:54 PM
Brad
@bradtaniguchi
Apr 16 2018 23:03
@zootechdrum without diving too deep into the code, this line newArray = myArr doesn't copy the array. Its the same array in memory, so any removing items affects both arrays.
Ken Haduch
@khaduch
Apr 16 2018 23:04
@zootechdrum - they are not necessarily on the same number - you might have i pointing to one place, and h pointing to the place where the duplicate is, for example. You might find it interesting to take that code to http://pythontutor.com/javascript.html and plug it in and step through it with some examples.
zootechdrum
@zootechdrum
Apr 16 2018 23:06
@khaduch what a great resource that should be added to freecodecamp somewhere
Ken Haduch
@khaduch
Apr 16 2018 23:07
@zootechdrum - it's a nice tool for the right problems - so useful!
zootechdrum
@zootechdrum
Apr 16 2018 23:08
going to share with my local freecodecamp group. Again thanks man!
Ken Haduch
@khaduch
Apr 16 2018 23:09
and @bradtaniguchi made a good point - the newArr = myArr is not making a new copy of the array, that only makes a reference to the same array. That could be a problem in solving this.
Brad
@bradtaniguchi
Apr 16 2018 23:09
Its the gotcha, definantly. Also why does pythontutor have a javascript tutor haha
zootechdrum
@zootechdrum
Apr 16 2018 23:10
@bradtaniguchi thanks to you too
CamperBot
@camperbot
Apr 16 2018 23:10
zootechdrum sends brownie points to @bradtaniguchi :sparkles: :thumbsup: :sparkles:
:cookie: 462 | @bradtaniguchi |http://www.freecodecamp.org/bradtaniguchi
Ken Haduch
@khaduch
Apr 16 2018 23:12
@bradtaniguchi - good question! :)
Ashraf Patel
@AshrafPatel
Apr 16 2018 23:13
@khaduch thank you
CamperBot
@camperbot
Apr 16 2018 23:13
ashrafpatel sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3884 | @khaduch |http://www.freecodecamp.org/khaduch
Ashraf Patel
@AshrafPatel
Apr 16 2018 23:25
@todorare thank you
Teo
@todorare
Apr 16 2018 23:25
No problem
Ashraf Patel
@AshrafPatel
Apr 16 2018 23:25
@abe312 thank you
CamperBot
@camperbot
Apr 16 2018 23:25
ashrafpatel sends brownie points to @abe312 :sparkles: :thumbsup: :sparkles:
:cookie: 346 | @abe312 |http://www.freecodecamp.org/abe312
kyle-kauzlarich
@kyle-kauzlarich
Apr 16 2018 23:36
hmmmmmm
whats going on here?
Brad
@bradtaniguchi
Apr 16 2018 23:38
nothing >.>
kyle-kauzlarich
@kyle-kauzlarich
Apr 16 2018 23:39
thats a shame