These are chat archives for FreeCodeCamp/HelpFrontEnd

14th
Sep 2018
Abhishek Katiyar
@abhishekkatiyar
Sep 14 2018 05:52
are we allowed to use Google Fonts in projects ?
Aditya
@ezioda004
Sep 14 2018 05:53
@abhishekkatiyar Yes
Abhishek Katiyar
@abhishekkatiyar
Sep 14 2018 05:54
Thanks @ezioda004
Abhishek Katiyar
@abhishekkatiyar
Sep 14 2018 06:21
please provide you valuable feedback on my projects https://codepen.io/abhishekkatiyar/full/dqKEJj/
Technical Documentation Project: https://codepen.io/abhishekkatiyar/pen/rZKgrw
Abhishek Katiyar
@abhishekkatiyar
Sep 14 2018 07:01
*your
Ion Varsescu
@Nei-V
Sep 14 2018 09:33
Hello, anyone here can help with react?
VitaliiLynnyk
@VitaliiLynnyk
Sep 14 2018 10:14
@Nei-V you should ask question, we are all learning here
Bradley Sands
@sandsbe
Sep 14 2018 11:10
Good morning! Anyone know why the "days in a row" feature was discontinued on the revamp? Is it somewhere?
AJ Brommy
@AJ-Brommy
Sep 14 2018 13:49
@abhishekkatiyar i looked at portfolio, clicked on the button to view product landing page and nothing happened. Tried the other two too, same thing. Other than that tho. nice :)
Abhishek Katiyar
@abhishekkatiyar
Sep 14 2018 15:20
@AJ-Brommy It is working on my Chrome browser, btw which browser do you use ?
@AJ-Brommy Thanks for your response, you have to hover on 'view' to make the button visible
AJ Brommy
@AJ-Brommy
Sep 14 2018 16:03
OK - it does work, now you've said that. But that could be a little confusing for users. When I hover over the landing page area it enlarges like buttons often do, and also the mouse cursor changes. All things that make it appear clickable. Like me, most users probably won't think to hover over the little bit that says "view" to be the button, I would either make the whole area clickable, or make the "view" stand out more as a button itself. Personally I'd opt for the first option. But ultimately its yours and upto you. Those are just my opinions. I use alsorts of browsers by the way, i was using Opera, it does work fine in Opera, now I know where to click :)
Abhishek Katiyar
@abhishekkatiyar
Sep 14 2018 17:06
@AJ-Brommy Thanks for sharing your opinion. I will add click action to div
Keegan
@Keggatron
Sep 14 2018 21:33
Hi guys, is there anyway to write this more succinctly?
 let department = departments.find(_department => (
      _department.id === selectedArea.departmentId
    ));
    department = department.shortDescription;
like is there any array iterator where I can find an object by a property, then return another property from that object in the same function?
Brad
@bradtaniguchi
Sep 14 2018 21:36
@Keggatron nope, and your code blows up if you dont find the deparment too
newmoon
@newmoon
Sep 14 2018 22:02
@Keggatron It depends on what you mean by "succinct". The code is readable as you have it, but not very good performance for large objects, as you can't break out of the .find() loop once you get a match.
Brad
@bradtaniguchi
Sep 14 2018 22:04
@newmoon find breaks out of the loop when you find the match no?
newmoon
@newmoon
Sep 14 2018 22:05
@bradtaniguchi No, it will iterate through the entire object
Just like .forEach() or .map()
Brad
@bradtaniguchi
Sep 14 2018 22:05
whaaaaa then whats the freaken point of find?
newmoon
@newmoon
Sep 14 2018 22:06
It will find it :) but that's a common problem with higher order functions.
need to basically throw an exception to stop the loop
Brad
@bradtaniguchi
Sep 14 2018 22:06
Are you sure?
newmoon
@newmoon
Sep 14 2018 22:06
I think this would be equally succinct and better performing:
let department;
for(const department in departments) {
  if (department.id === selectedArea.departmentId) {
    department = department.shortDescription;
    return;
  }
}
I'm 99% certain, but would love to be proved wrong. :)
Brad
@bradtaniguchi
Sep 14 2018 22:08
Looking at the polyfill on mdn for find, it returns the first item that matches
but let me check the impl on node
Yea it "breaks" once it meets the condition and does not iterate over the rest of the array.
newmoon
@newmoon
Sep 14 2018 22:10
Looking at it on MDN, it says it returns the first matching item. Objects don't have guaranteed order though - so not sure if there would be implications where multiple matches could be found.
Brad
@bradtaniguchi
Sep 14 2018 22:10
you cant use find on an object
newmoon
@newmoon
Sep 14 2018 22:11
Sorry, array (which is an object) :)
Brad
@bradtaniguchi
Sep 14 2018 22:11
if you wanted multiple matches you use filter, which is basically the same, but goes over all the items
arrays have guaranteed order
newmoon
@newmoon
Sep 14 2018 22:14
Yes, arrays are indexed. Maybe I'm overlooking something, but seems this is an array of JSON objects.
Brad
@bradtaniguchi
Sep 14 2018 22:15
an array has order regardless of whatever is in the array
newmoon
@newmoon
Sep 14 2018 22:16
Thank you for pointing out the break; I'll look into that some more!
Brad
@bradtaniguchi
Sep 14 2018 22:16
maybe your getting confused with the order of keys in an object? Object.keys(obj)// this has no guarentee
newmoon
@newmoon
Sep 14 2018 22:17
Yes, was thinking of the order of keys in a JSON object in that array: [{}, {}, {}]
I don't know why... but the for loop looks cleaner to me lol, maybe I'm just so used to ES5 still
Brad
@bradtaniguchi
Sep 14 2018 22:18
I mean technically find is a 1 line solution, and those are sexy :p
newmoon
@newmoon
Sep 14 2018 22:22
lol
Lia-Sue-Kim
@Lia-Sue-Kim
Sep 14 2018 23:06
hello
when you make a contact form with php for a website that is online with a hosting company
where to put php code
i mean i know that it works inside html between php tags
Brad
@bradtaniguchi
Sep 14 2018 23:08
@Lia-Sue-Kim in the php file?
Lia-Sue-Kim
@Lia-Sue-Kim
Sep 14 2018 23:08
but i have public domain
Brad
@bradtaniguchi
Sep 14 2018 23:08
idk much about php, but I know it needs to be ran on the server, id check with your hosting provider on how to run php
Lia-Sue-Kim
@Lia-Sue-Kim
Sep 14 2018 23:08
yeah but is it ok to put that php file inside public html
they have php mysql seperately
and public domain is deperated as well
Brad
@bradtaniguchi
Sep 14 2018 23:10
if you put php code in an html file its just text,
again, check with how your suppose to use php on your hosting provider
Lia-Sue-Kim
@Lia-Sue-Kim
Sep 14 2018 23:10
ok even in between php tags?
ok
when you ask them about coding they don't really help
if you wanna buy a package they are friendly lol
Brad
@bradtaniguchi
Sep 14 2018 23:17
id switch providers if their documentation is lacking
unless you know what your doing
AJ Brommy
@AJ-Brommy
Sep 14 2018 23:36

hey dude, sorry i wasn't paying attention to the room... if your hosting has php and mysql putting php files in your root directory should work. public_html is usually a root directory name. don't be thrown by mention of html. create a file called phpinfo.php and inside it put

<? phpinfo(); ?>

upload that file to your public_html or root folder and then goto your url in the browser www.yourpublicdomain.com/phpinfo.php and see what happens

if that fails then something is wrong. if it works. then you are good to go. but you might wanna delete that file after you've used it to test the servers

php works like this...

<!DOCTYPE HTML>
<html>
    <head>
        <title>Example</title>
    </head>
    <body>

        <?php
            echo "Hi, I'm a PHP script!";
        ?>

    </body>
</html>

but instead of saving the file with the extension .html it has to have .php

AJ Brommy
@AJ-Brommy
Sep 14 2018 23:41
oh sorry just read back your first question. there are 2 ways to achieve it. one is to put the code in the same file. but the file must have the .php extension. often this is done with the php code at the top of the page so...
<?php
    // php form code here
?>
<html>
<!-- html code and form here -->
</html>
or you can use a separate file... and then within the file once the code is complete you can redirect to a new page or original form page, or whatever you want to happen next.
or you can actually do a mixture. so the code that you would put at the top of the page goes in a separate file but then you include("filename.php") it
AJ Brommy
@AJ-Brommy
Sep 14 2018 23:47
<?php
   // include the php code to process the submitted form
  include("phpformcode.php")
?>
<html>
<!-- page code -->
<!-- This page must be also saved with a .php extension and not .htm or .html because it contains php tags it must therefore be a php file to be processed correctly -->
</html>
i'm not really sure what you meant by "they have php mysql seperately,
and public domain is deperated as well"?