These are chat archives for FreeCodeCamp/HelpFrontEnd

6th
Jun 2018
Aita Kane
@aita-kane
Jun 06 2018 00:28
hello can someone help me i'm having my require function not working
JW
@contactjw
Jun 06 2018 00:39
can you build entire layouts with just flexbox?
DarkxPunk
@DarkxPunk
Jun 06 2018 00:59
@contactjw Yes
abraham anak agung
@padunk
Jun 06 2018 02:19

@interactivenyc i usually wrap my route with Switch.

<Switch>
  <Route.... />
  <Route.... />
</Switch>

And i like to wrap my App.js with browser router in index.js

UnorthodoxThing
@UnorthodoxThing
Jun 06 2018 03:56
Hi all, I'm making a navbar menu for on a website where you click on the menus for it to display (instead of the usual hover-to-display). I'm using Html/CSS and Javascript (and Jquery lib). The problem is when I click on the menu to display it appears to float way to the left and not just underneath the menu tab I selected. Is there a way to position them just in one column?
Here is my work in progress: https://codepen.io/UnorthodoxThing/pen/MXemeW
I'm working on the "menu" tab
Claudio Restifo
@Marmiz
Jun 06 2018 04:18
@UnorthodoxThing you can use .offset() from jQuery to know the position of the button, and then assign left to the ul based on that :)
UnorthodoxThing
@UnorthodoxThing
Jun 06 2018 04:55
thx! :D I was just messing with the margins and was able to reposition it
Claudio Restifo
@Marmiz
Jun 06 2018 05:14
@UnorthodoxThing yep, but is it calculated with a function?
otherwise you don't know how it will behave for different screen sizes
Deepak Gowda
@Deep2322_twitter
Jun 06 2018 08:58
i am implementing routing in my project, i update the view on click on some button which will update the state and also update the url "components/profile/283". let's say "components/profile" is my base url. During the update state i.e "components/profile/283" when i reload page i get "404". But when i add "#" after the base url i.e "components/profile/#/283" it persists the page and data. Does anyone know why should i add "#" after the base url ?
Aita Kane
@aita-kane
Jun 06 2018 10:31
Hello everyody I have a wsite where the user logged in before having access to others pages. I want to know if it's possile to hash the password of my admin in the php, echo it then i will know the password hash and then store it in the database. ecause only the admin can add user in the database and when he add it, those passwords will be hash. And what i don't want all the passwords in my user table to be hashed expect the admin one. Do you think that my solution is correct ? If no what would you suggest me to do. Thanks for the help/advice .
tundeiness
@tundeiness
Jun 06 2018 11:55
hi everybody. Now the new FCC curriculum is massive!!!! but I have some worries. Unlike before once we are done with the frontend we will be awrded a certificate. But this time around does the previous condition hold? Or do we need to complete everything in this new curriculum to qualify for a certificate?
Tom
@moT01
Jun 06 2018 13:51
@tundeiness there's 6 new certificates - you only need to complete the required projects in each section to get the certificate for that section
tundeiness
@tundeiness
Jun 06 2018 13:56
@moT01 okay. But the arrangement does not look like so.
Tom
@moT01
Jun 06 2018 14:01
@tundeiness if you go to your settings page and scroll down to the certification settings area
it says Add links to the live demos of your projects as you finish them. Then, once you have added all 5 projects required for a certification, you can claim it.
tundeiness
@tundeiness
Jun 06 2018 14:05
@moT01 okay. I'll check that out.
BWr3dw00d
@BWr3dw00d
Jun 06 2018 14:19
Hey guys...I am trying to write a program that will define a triangle as Isosceles, Equilateral or Scalene. It is 1/3 coding challenges I need to pass in order to get in to a Software development apprenticeship program
Can you tell whats wrong with my code?

"var side1 = 2;
var side2 = 2;
var side3 = 2;

if(side1==side2==side3){
console.log("Equilateral");
}else if ((side1===side2 !=side3) || (side2===side3 !=side1) || (side3===side1 !=side2)) {
console.log("Isosceles");
}else {
console.log("Scalene");
}
"

Marianissimus
@Marianissimus
Jun 06 2018 14:25
@BWr3dw00d equality btw 3 items like var1 === var2 === var3? I don't know of such things:(
You could use
if (var1 === var2 && var2 === var3){}
Nazar
@IsaakNazar
Jun 06 2018 14:41
@BWr3dw00d

            if(side1 === side2 && side1 === side3)
            {
                console.log('Equilateral');                
            } 
            else if(side1 === side2 || side1 === side3 || side2 === side3)
            {
                console.log('Isosceles');
            } 
            else
            {
                console.log('Scalene');                
            }
Brad
@bradtaniguchi
Jun 06 2018 16:35
I feel like that challenge could be extra harder if you dont know which sides are the isosceles sides your suppose to equal hehe
Alexandar B
@ace1122sp
Jun 06 2018 16:56
hi guys... so, i'm building a voting app using react and redux on client side and I have some issue with updating my component... The component receives updated props from container but it doesn't rerender.. and I also tried to fix that with shouldComponentUpdate() but it still doesn't work.. here's my implementation of shouldComponentUpdate()...
shouldComponentUpdate(nextProps) {
    const count = this.props.options.length;
    for(let i = 0; i < count; i++) {
      if (this.props.options[i].votes !== nextProps.options[i].votes) return true;
    }
    return false;
  }
and here's the reducer piece of code...
...
case 'ADD_VOTE':
      let pool = Object.assign({}, state[action.pool]);
      pool.options[action.option].votes += 1;
      return Object.assign({}, state, {[action.pool]: pool});  
...
Mois├ęs Man
@moigithub
Jun 06 2018 17:06
.... IF u remove shouldComponentUpdate or always return true.. does it rerenders ? @ace1122sp
Alexandar B
@ace1122sp
Jun 06 2018 17:09
@moigithub no..
in both cases
it's like shouldComponentUpdate() never gets called...
Alexandar B
@ace1122sp
Jun 06 2018 18:20
finally, fixed.. huh.. it took me almost the whole afternoon to fix it.. :sweat_drops: :sweat_smile:
Daniel
@dbsimeonov
Jun 06 2018 19:23
Guys is there any way I can check on google maps which pointer/marker is clicked? I'm currently playing with its API
richRocksCodeBlocks
@richRocksCodeBlocks
Jun 06 2018 19:27
Daniel
@dbsimeonov
Jun 06 2018 19:59
Actually I made it work the addListener (my issue was that I tried to do Event, and the other issue I faced is that the marker returns me a lot of objects that I can not find any of them I can compare or follow which one is clicked(as I have more than 10)
mustimuu
@mustimuu
Jun 06 2018 20:03

@mustimuu
Hello can someone help me

On my wordpress site, i have on th top-header, Danish language and english. When i press the danish language the language selection doesent appear
it looks very different

Brad
@bradtaniguchi
Jun 06 2018 20:07
@mustimuu It could be a lot of things, and idk how many people have wordpress experience here
Connor
@cresharper
Jun 06 2018 20:12
I have a modal that I want to close if the user clicks off of it. I'm trying to use e.target to have it so that if the target is not the button, the modal will close. See the example here: http://jsfiddle.net/6qgbs8yx/2/
The relevant code sample:
$(function(e) {

  $("#filter-button").click(function(e) {
    $(".dialog").toggleClass("show");
  });

  if(e.target.tagName.toLowerCase() != 'button') {
    $(".dialog").removeClass("show");
  }

});
I tried console logging e.target but nothing comes out. What's going on? What am I doing wrong?
newBorn
@_new_born_twitter
Jun 06 2018 20:35
Hey guys, How do you compare 2 different JSON data?
Brad
@bradtaniguchi
Jun 06 2018 20:37
@_new_born_twitter You probably need todo a deep compare, if you want to know if the data is equal
newBorn
@_new_born_twitter
Jun 06 2018 20:39
thanks. @bradtaniguchi For example - i have one json file that contains data for multiple choice questions and another file contains answers from users
example of qustion json -[ {"title": "Question 1",
"questionType": "singleChoice",
"alternatives": [32, 4, 9],
"correctAlternativesIndex": [1] }]
and answers - [
{"alternativesIndex": [2]},
{"alternativesIndex": [0]}, ]
Brad
@bradtaniguchi
Jun 06 2018 20:42
uh, this seems like a complex buiness use case
newBorn
@_new_born_twitter
Jun 06 2018 20:42
now i want to compare answers with every question
oh :worried:
Brad
@bradtaniguchi
Jun 06 2018 20:43
Its hard to tell what is what, why are answers values objects with alternativesIndex? whats an alternativeIndex?
and in the questions you have alternatives array which are just numbers, unless these are the values of the answer?
newBorn
@_new_born_twitter
Jun 06 2018 20:43
alternativeIndex is the answer that user has given
Brad
@bradtaniguchi
Jun 06 2018 20:44
finally when you say compare, what do you want exactly? which answers are correct, arrays of true/false, etc
newBorn
@_new_born_twitter
Jun 06 2018 20:44
yes in question file alternatives are the choice of answers
Brad
@bradtaniguchi
Jun 06 2018 20:45
what?
newBorn
@_new_born_twitter
Jun 06 2018 20:45
by compare, I mean I want to see if "alternativesIndex" from the answer file matches with the corresponding "correctAlternativesIndex" from question file
BWr3dw00d
@BWr3dw00d
Jun 06 2018 20:48
@Marianissimus Thanks...it was a rookie move. Im just learning Javascript.
Brad
@bradtaniguchi
Jun 06 2018 20:48
There a few other edge cases, like if the user answers only some of the questions, what happens (the questions length and the answers are different) what happens if the user selects an answer thats right, but theres more than 1 answer, and if the user selects the right answer and a wrong answer (multiple-choice). Again its pretty complex, I don't think I (or anyone else) has the time to go over the entire approach, other than start by iterating over the questions and checking the answers
newBorn
@_new_born_twitter
Jun 06 2018 20:49
some questions have multiple right answer. In that case I want to give partial points for every right answer
the question json actually looks like this - "questions": [
{
"title": "Question 1",
"questionType": "singleChoice",
"alternatives": [32, 4, 9],
"correctAlternativesIndex": [1]
}, ... ]
and the answer looks like - "answers": [
{"alternativesIndex": [2]},
....
]
Brad
@bradtaniguchi
Jun 06 2018 20:51
I understand, you already posted that. I can't help you unfortunately. Your requirement is too complex to explain in any reasonable amount of time, especially if your starting from the ground up
newBorn
@_new_born_twitter
Jun 06 2018 20:51
in the case of multiple right answer, the "questionType" will be "multiple"
I actually created a command line app that reads the 2 files and parse the json and store them to 2 variables. Now I need to check the answers
@bradtaniguchi thanks anyway
anyone else have any idea how to proceed with this?
Brad
@bradtaniguchi
Jun 06 2018 20:56
@_new_born_twitter np, if you break your requirements down to something more manageable someone prolly would help, but right now its more or less how do I do everything
newBorn
@_new_born_twitter
Jun 06 2018 21:00
haha okej. what would be a simpler case here ?
Brad
@bradtaniguchi
Jun 06 2018 21:00
idk, it depends on what you dont' understand
idk if you even know how to iterate of the questions, not saying you don't know how, its just I really have no idea what your actually stuck on
Gulsvi
@gulsvi
Jun 06 2018 21:02
@_new_born_twitter what code have you written so far? Maybe we can start there.
newBorn
@_new_born_twitter
Jun 06 2018 21:02
i used/would have used for and/map+filter to achieve something. but it was getting too dirty , I thought
that is why I was wondering if there was any better way to do this
@gulsvi thanks. Right now, I am reading those files (questions and answers) , parsing the json and assigning those to variables
Brad
@bradtaniguchi
Jun 06 2018 21:05
I think we understand the inputs of the problem, but we don't understand what you want as the output of this code, or how to determine the output (you mention partial points, but thats only in passing)
newBorn
@_new_born_twitter
Jun 06 2018 21:07
It should print the result of each answer and points. If an answer is incorrect , it should print the correct answer.
Brad
@bradtaniguchi
Jun 06 2018 21:07
What do you mean result?
and I see no where in this code the text of the answer, so that's not possible with what we have
newBorn
@_new_born_twitter
Jun 06 2018 21:08
i mean if it's correct or not + the point
@bradtaniguchi text of the answer?
Gulsvi
@gulsvi
Jun 06 2018 21:09
@_new_born_twitter Use codepen.io to create a prototype that shows the problem you're hitting. This is all kind of abstract at the moment - and not a Free Code Camp front end development project
newBorn
@_new_born_twitter
Jun 06 2018 21:10
@gulsvi thanks. sure I can do that.
Gulsvi
@gulsvi
Jun 06 2018 21:10
Like Brad Said above, we don't really know what you're stuck on specifically ;)
Brad
@bradtaniguchi
Jun 06 2018 21:12
yea forgot about putting it on codepen :P
newBorn
@_new_born_twitter
Jun 06 2018 21:26
sorry about that. here is what I have done so far. It won't run on codepen though cuz it meant to run on cmd line
Brad
@bradtaniguchi
Jun 06 2018 21:44
I dont think you need to include the cli stuff. Just the data the cli part gets, and the variables.
newBorn
@_new_born_twitter
Jun 06 2018 21:52
ok
@bradtaniguchi updated variables with JSON
richRocksCodeBlocks
@richRocksCodeBlocks
Jun 06 2018 21:59