These are chat archives for FreeCodeCamp/HelpFrontEnd

24th
Apr 2018
Moisés Man
@moigithub
Apr 24 2018 00:03
what this does ? rng.nextInt(chain.size()) @Devansh-Anhal
Santiago Fernandez
@sf-jd
Apr 24 2018 00:53
i always forget where the actual talking takes place here :/
Have a few Js doubts, im submitting some code for an interview, and some questions came up regarding style which i
d like to talk over if anyone's around :D
Brad
@bradtaniguchi
Apr 24 2018 01:01
Style is great, since anyone can talk about style and no one is right XD
Santiago Fernandez
@sf-jd
Apr 24 2018 01:01
well, not style tbh
im just not sure about some things that i know work, but wonder if its the correct way to write it :/
like maybe im overextracting stuff into functions. i try not to compromise legibility and "ease of following wtf is going on"
but then again, DRY stabs me in the face and i HAVE to avoid repeating stuff :D
all in all im not satisfied that the implementation works, but i'd like the code to look nice... despite the fact they know i havent worked more than a few freelance projects (and you pretty much make up the rules as you go there)
Brad
@bradtaniguchi
Apr 24 2018 01:04
I mean its really realtive. Do you know if you can find out if the company your submitting your code to has any style guides? (might be able to do some digging)
otherwise the general stuff should be ok. Idk if you code looks like a mess so idk past that
Santiago Fernandez
@sf-jd
Apr 24 2018 01:04
they dont, one of their front end leads is a good friend of mine and he agrees on my approach "i dont know everything, this is the best i can do"
mayhaps just need to vent it out a bit and then click the send button with what i've got :D
Brad
@bradtaniguchi
Apr 24 2018 01:05
I mean i don't see how style could hurt you as long as its not total garbage haha
Santiago Fernandez
@sf-jd
Apr 24 2018 01:05
take the following
function a(){
 functionb()
functionc()
functiond()
}
i just feel that is dirty for some reason
but it does help me handle an event on the browser in multiple places, by using a() and keeping each eventhandler short
Brad
@bradtaniguchi
Apr 24 2018 01:07
I usually don't nest functions, unless there's some sort of OOP going on
were talking about vanillajs right? Opens up alot of ideas on style
Santiago Fernandez
@sf-jd
Apr 24 2018 01:08
yea
constraint is use no libraries, no frameworks, just vanilla
Brad
@bradtaniguchi
Apr 24 2018 01:09
Yea, id still stick with the no nested function thing (besides an Iffe)
Santiago Fernandez
@sf-jd
Apr 24 2018 01:10
so just repeat the code?
i am wrapping all those methods (b,c,d) inside another method basically, that is my approach, to avoid repeating like a madman and spanning 150 more lines of code
Brad
@bradtaniguchi
Apr 24 2018 01:11
what? whats wrong with:
function a() {
  addEventListener.on('click', b);
//...
}
function b() {}
function c() {}
function d() {}
Unless your using the same functions, (b,c,d) on different elements or something I'm missing
Santiago Fernandez
@sf-jd
Apr 24 2018 01:12
yea i am
i have click handlers for left arrow, right arrow, and then a nav with different positions
Brad
@bradtaniguchi
Apr 24 2018 01:12
Ah, I guess the naming of b,c,d isn't the best :P
Santiago Fernandez
@sf-jd
Apr 24 2018 01:12
rofl
Brad
@bradtaniguchi
Apr 24 2018 01:14
In that case i think its ok. Id probably keep the functions out of the main function just to then you can use them seperatly in special cases.
Santiago Fernandez
@sf-jd
Apr 24 2018 01:15
handleRightClick(){
 currentPosition += 1;
doStuffWithPosition() #this is where all the other handlers are
}

handleLeftClick(){
 currentPosition -=1;
doStuffWithPosition() #same handlers
}

goToPosition(e){
 currentPosition = e.target.dataattribute;
doStuffWithPosition() #again same handlers
}

doStuffWithPosition(){
 stuff();
 moreStuff();
 yetMoreStuff()
}
oh wow that pseudocode.
i felt that's cleaner than just one function with a switch or if/else inside... handling left, right and passing position.
as handleRightClick or handleLeftClick also let me use arrow keys and i just debounce those, withouth extending their bodies with more logic.
Brad
@bradtaniguchi
Apr 24 2018 01:18
I guess it depends on the use-case haha
Santiago Fernandez
@sf-jd
Apr 24 2018 01:18
:)
thanks @bradtaniguchi
CamperBot
@camperbot
Apr 24 2018 01:20
sf-jd sends brownie points to @bradtaniguchi :sparkles: :thumbsup: :sparkles:
:cookie: 468 | @bradtaniguchi |http://www.freecodecamp.org/bradtaniguchi
Brad
@bradtaniguchi
Apr 24 2018 01:21
@sf-jd np and goodluck, I think you should be fine :D
Santiago Fernandez
@sf-jd
Apr 24 2018 01:21
fingers crossed
Jesse Ross-Huffman
@jecmstudios
Apr 24 2018 01:26
So I'm stuck on the beginner's front-end project, I just feel scared of being on my own. I need inspiration.
Thomas Tylek
@zippkidd
Apr 24 2018 01:30
@jecmstudios what do you have to do for that project?
Is the example codepen given not enough inspiration? Lol
hansUno2
@hansUno2
Apr 24 2018 02:52
@jecmstudios break the project down into steps. Develope an algorithm/recipe for how you will get from blank page to final result before evening writing any code. Its like building a house, you get your ideal design and you change things as you go. This helps you to avoid freestyle coding which can lead to frustration.
zootechdrum
@zootechdrum
Apr 24 2018 03:13
@jecmstudios plan plan plan.
@ehutchllew no i got it it was just returning a promise
Lallo Vigil
@lalov1
Apr 24 2018 03:55
@jecmstudios I can help! Let me know with what
I mocked up the react recipe project. Please let me know some hints on how I will save the items in state and pass them using props: https://codepen.io/lalov1/pen/97756811476267a589a730dc15f881a1?editors=0010
Claudio Restifo
@Marmiz
Apr 24 2018 04:09

@lalov1 you just make your child component "dumb", in the sense that both the data and the method to change that date comes from the parent, the child only purpose is to render the latter:

An example would be:

const child = ({value, onChange}) => (<div onClick={() => onChange()}>{value}</div>)

class Parent [...] {
 state={value: 1}
 onChange = () => this.setState({value: this.state.value +1})

 render() {
  return (<Child value={this.state.value} onChange={this.onChange} />)
}
}

hope it helps :+1:

Jesse Ross-Huffman
@jecmstudios
Apr 24 2018 04:16
Thank you guys all of you helped. I just have always frozen up when I feel left on my own.
habibaatify
@habibatify_twitter
Apr 24 2018 04:30
hello
any one who know latex?
coderNewby
@coderNewby
Apr 24 2018 06:24
@DarrenfJ thanks for the pm
CamperBot
@camperbot
Apr 24 2018 06:24
codernewby sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2472 | @darrenfj |http://www.freecodecamp.org/darrenfj
anthonygallina1
@anthonygallina1
Apr 24 2018 06:40
:)
shameem fairooz
@sfshameem5
Apr 24 2018 06:42
Guys, I've completed the Electronic Calculator Project! Any suggestions ?
Markus Kiili
@Masd925
Apr 24 2018 06:45
@sfshameem5 Do you have a link for the working calculator?
shameem fairooz
@sfshameem5
Apr 24 2018 06:45
The github pages link
Markus Kiili
@Masd925
Apr 24 2018 06:45
:+1:
Roman Struna
@RomchyFCC
Apr 24 2018 06:46
@sfshameem5 it's awesome that you played around with cursor color and shape, but the cursor is almost impossible to see on the equals button, just a thought
shameem fairooz
@sfshameem5
Apr 24 2018 06:46
@RomchyFCC Would have to change that.
Markus Kiili
@Masd925
Apr 24 2018 06:47
@sfshameem5 I think that the calculator needs to have decimal numbers too.
shameem fairooz
@sfshameem5
Apr 24 2018 06:48
@Masd925 Is it a must ?
I've fulfilled the user stories for the project.
Markus Kiili
@Masd925
Apr 24 2018 06:48
@sfshameem5 It needs to be functionally similar to the referenced calculator.
shameem fairooz
@sfshameem5
Apr 24 2018 06:49
@Masd925 Will implement that and let you know, thanks
CamperBot
@camperbot
Apr 24 2018 06:49
sfshameem5 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4792 | @masd925 |http://www.freecodecamp.org/masd925
shameem fairooz
@sfshameem5
Apr 24 2018 06:50
@RomchyFCC Thanks
Markus Kiili
@Masd925
Apr 24 2018 06:50
@sfshameem5 You will also learn a lot if you make it work with decimal numbers too.
And don't use eval :imp:
:)
Roman Struna
@RomchyFCC
Apr 24 2018 06:51
Oh that's why the numbers suddenly got blocked and wouldn't calculate, interesting
Jefferson
@jeffersonnnn
Apr 24 2018 07:17
hi guys, i am looking to share my quotes from the random generator app to twitter. Is there a library or something i can use in the React ecosystem i can use?
hansUno2
@hansUno2
Apr 24 2018 07:21
@jeffersonnnn search for qoutesOnDemand API
shameem fairooz
@sfshameem5
Apr 24 2018 07:23
@Masd925 If not eval, what else ?
Markus Kiili
@Masd925
Apr 24 2018 07:24
@sfshameem5 You could make an expression parser that evaluates the typed expression.
shameem fairooz
@sfshameem5
Apr 24 2018 07:25
@Masd925 A function which does that ?
Markus Kiili
@Masd925
Apr 24 2018 07:25
@sfshameem5 Yes.
shameem fairooz
@sfshameem5
Apr 24 2018 07:25
@Masd925 Is it bad to use eval() for calculations ?
hansUno2
@hansUno2
Apr 24 2018 07:26
Yes.. Even the docs say to never use it
Markus Kiili
@Masd925
Apr 24 2018 07:26
@sfshameem5 Using eval is bad for security and performance reasons, so you should avoid it.
shameem fairooz
@sfshameem5
Apr 24 2018 07:26
@Masd925 Will modify and let you know.
Markus Kiili
@Masd925
Apr 24 2018 07:27
@sfshameem5 There are known algorithms for parsing expressions, but you can also do your own by making the expression simpler and simpler starting from the highest priority operations etc.
shameem fairooz
@sfshameem5
Apr 24 2018 07:28
@Masd925 Which one would you recommend ?
Markus Kiili
@Masd925
Apr 24 2018 07:28
@sfshameem5 Whatever suits you.
Jefferson
@jeffersonnnn
Apr 24 2018 07:28
@hansUno2 thanks man, but i am not looking for an API for quotes. I am looking to share the quotes, and i haven't been able to get the method
CamperBot
@camperbot
Apr 24 2018 07:28
jeffersonnnn sends brownie points to @hansuno2 :sparkles: :thumbsup: :sparkles:
:cookie: 16 | @hansuno2 |http://www.freecodecamp.org/hansuno2
shameem fairooz
@sfshameem5
Apr 24 2018 07:29
@Masd925 Will try the second option.
hansUno2
@hansUno2
Apr 24 2018 07:29
@jeffersonnnn to post it on twitter?
Jefferson
@jeffersonnnn
Apr 24 2018 07:30
@hansUno2 yes yes
shameem fairooz
@sfshameem5
Apr 24 2018 07:30
hansUno2
@hansUno2
Apr 24 2018 07:31
@jeffersonnnn you have to read the directions on the twitter page, no API needed
Jefferson
@jeffersonnnn
Apr 24 2018 07:31
@sfshameem5 thanks man. i appreciate
CamperBot
@camperbot
Apr 24 2018 07:31
jeffersonnnn sends brownie points to @sfshameem5 :sparkles: :thumbsup: :sparkles:
:cookie: 310 | @sfshameem5 |http://www.freecodecamp.org/sfshameem5
hansUno2
@hansUno2
Apr 24 2018 07:32
@sfshameem5 how are you calculating you expression with your calc app?
I tried it but could no get an answer
Jefferson
@jeffersonnnn
Apr 24 2018 07:34
@hansUno2 could you show me directions to this page?
shameem fairooz
@sfshameem5
Apr 24 2018 07:34
@hansUno2 Used eval() but it ain't recommended. Might have to create a function to validate expressions
hansUno2
@hansUno2
Apr 24 2018 07:34
@jeffersonnnn
Jefferson
@jeffersonnnn
Apr 24 2018 07:37
@hansUno2 so i went to the link and i am going through the javascript api end. The problem however is that i am building my app in React, not pure js
hansUno2
@hansUno2
Apr 24 2018 07:38
@jeffersonnnn read this section--> "How to add a Tweet button to your websit". the link posted by @sfshameem5
@jeffersonnnn not sure how you would do it with react
@sfshameem5 are the numbers being displayed in an input element?
Javier Pons
@JavierPons
Apr 24 2018 07:41
Hi there!
<html>
  <h1>Type a number between 1 - 10</h1>
  <form action="" name="form1">
    <input type="text" name="text" width="20px">
    <button onClick="init()">Press</button>
  </form>

</html>
var numb = Math.floor(Math.random() * 10 +1);

function init() {
  var inicio = document.form1.text.value;
  console.log("coge");
}

function check() {
  var count = 0;
  var acept = init();


   if(acept == numb) {
     showWin();
     count++;
   } else if( acept !== numb) {
             showError();
     count++;
   } else if((acept !== numb) && (count == 5 )) {
     showLoss();
     count++;
   }

}

function showWin() {
  console.log("gano!");
}

function showError() {
  console.log("perdio");
}

function showLoss() {

  console.log("mas de cinco veces, perdio");
}
hansUno2
@hansUno2
Apr 24 2018 07:43
Hi
shameem fairooz
@sfshameem5
Apr 24 2018 07:43
@hansUno2 A <div> element
Javier Pons
@JavierPons
Apr 24 2018 07:43
is it function init() taking the value of the input?
some vision, if you can ...
hansUno2
@hansUno2
Apr 24 2018 07:45
No
Claudio Restifo
@Marmiz
Apr 24 2018 07:47
@JavierPons it's onclick in vanilla JS, onClick is general for react, vue and the other frameworks
hansUno2
@hansUno2
Apr 24 2018 07:47
Document.form1.text is not defined as far as i can see
Javier Pons
@JavierPons
Apr 24 2018 07:47
ok!
Claudio Restifo
@Marmiz
Apr 24 2018 07:49
@JavierPons then to get the input value it's probably way easier to use getElementByID().value
Javier Pons
@JavierPons
Apr 24 2018 07:49
you are right!
hansUno2
@hansUno2
Apr 24 2018 07:49
@JavierPons yes. Or querySelector
You have to specify the elemen name , class, or id
Javier Pons
@JavierPons
Apr 24 2018 07:54
:+1:
Javier Pons
@JavierPons
Apr 24 2018 07:59
@Marmiz @hansUno2 thanks!
CamperBot
@camperbot
Apr 24 2018 07:59
javierpons sends brownie points to @marmiz and @hansuno2 :sparkles: :thumbsup: :sparkles:
:cookie: 17 | @hansuno2 |http://www.freecodecamp.org/hansuno2
:star2: 1214 | @marmiz |http://www.freecodecamp.org/marmiz
Sundeep
@pidugusundeep
Apr 24 2018 08:07
@camperbot thanks
CamperBot
@camperbot
Apr 24 2018 08:07
pidugusundeep sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 3428 | @camperbot |http://www.freecodecamp.org/camperbot
Jefferson
@jeffersonnnn
Apr 24 2018 08:56
hi guys, i need to know if there is a React implementation for the TweetButton feature of Twitter?
shameem fairooz
@sfshameem5
Apr 24 2018 09:18
@Masd925 Would the math.js library be okay to use ? It has the math.eval() function which makes it easy
Markus Kiili
@Masd925
Apr 24 2018 09:20
@sfshameem5 I think that you can use libraries like that. I would still try to do it first on my own.
shameem fairooz
@sfshameem5
Apr 24 2018 09:20
@Masd925 I feel it a lot more difficult to do on my own.
Markus Kiili
@Masd925
Apr 24 2018 09:21
@sfshameem5 It is, but then the project has a lot more value to it.
shameem fairooz
@sfshameem5
Apr 24 2018 09:22
@Masd925 I'll do it on my own.
Dmytro Holysh
@dmk1111
Apr 24 2018 10:13
Hi, guys!
Did anyone read book JavaScript for Kids ? What's your thoughts? Is it a good reading for beginner?
mustimuu
@mustimuu
Apr 24 2018 11:27
Can someone help me?
i want to give my own class to a element in wordpress. How do i add my own class?
Abdus Samad
@asamad123
Apr 24 2018 11:30
hi everyone
so i have this issue. I've got a navbar its set as display block, and when user scrolls it gets class addnav added. But the transition does not occure?
mustimuu
@mustimuu
Apr 24 2018 11:46
can someone help me
Abdus Samad
@asamad123
Apr 24 2018 11:46
what you need help on @mustimuu
mustimuu
@mustimuu
Apr 24 2018 11:46
@asamad123 i want to give my mega menu my own css class
but i can only do it with the a links not the whole bar?
i want to give it its own div, so i can play with it, with flexbox
Abdus Samad
@asamad123
Apr 24 2018 11:47
thats easy, mind sharing your code is it on codepen?
mustimuu
@mustimuu
Apr 24 2018 11:47
you can inspect it if you want
its the top widget
Abdus Samad
@asamad123
Apr 24 2018 11:48
so from what i understand you want to wrapp all the links in one div so you can display flex later?
mustimuu
@mustimuu
Apr 24 2018 11:49
@asamad123 yes
the whole widget area
Abdus Samad
@asamad123
Apr 24 2018 11:52
class="menu-widget-menu-container" why dont you wrap this in another div and add a class that will be used as flexbox container so you can add flexbox to it.
mustimuu
@mustimuu
Apr 24 2018 11:53
yes but how do i wrap it around a div sir?
Abdus Samad
@asamad123
Apr 24 2018 11:53
@mustimuu or add a class on the ul and display flex simple
mustimuu
@mustimuu
Apr 24 2018 11:53
its a widget in my header.file
Abdus Samad
@asamad123
Apr 24 2018 11:53
it will be hard to show it since its not in codepen, do you think you can add this to codepen i can give you an example
mustimuu
@mustimuu
Apr 24 2018 11:53
sure
@asamad123

<body <?php body_class(); ?>>

<div class="hfeed site" id="page">

<!-- ******************* The Navbar Area ******************* -->

<?php
if ( is_active_sidebar( 'header-top-menu' ) ) : ?>
<div id="header-top-menu" class="chw-widget-area widget-area" role="complementary">
<?php dynamic_sidebar( 'header-top-menu' ); ?>
</div>
<?php endif; ?>

<div id="wrapper-navbar" itemscope itemtype="http://schema.org/WebSite">

    <a class="skip-link screen-reader-text sr-only" href="#content"><?php esc_html_e( 'Skip to content', 'understrap' ); ?></a>

    <nav class="navbar navbar-expand-md navbar-dark bg-dark">

    <?php if ( 'container' == $container ) : ?>
        <div class="container" >
    <?php endif; ?>
ohh sorry
the top one in the link
Abdus Samad
@asamad123
Apr 24 2018 11:56
ok...lets do this another way
@mustimuu you gave me php snippet
mustimuu
@mustimuu
Apr 24 2018 11:58
yes
its the way the widget works
its build in php
thats why i want to wrap it around a div. but i dont know how in php
Abdus Samad
@asamad123
Apr 24 2018 12:00
OH ITS IN WORDPRESS, OK I CANT ACCESS IT SO I WONT BE ABLE TO DO THE DO THE EDITING.
mustimuu
@mustimuu
Apr 24 2018 12:00
@asamad123 exactly
Abdus Samad
@asamad123
Apr 24 2018 12:03
<ul id="menu-widget-menu" class="menu flexbox"><li id="menu-item-89" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-89"><a href="http://mustidev.beproductive.dk/">Forside</a></li>
<li id="menu-item-93" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-93"><a href="http://mustidev.beproductive.dk/gdpr-politik/">GDPR politik</a></li>
<li id="menu-item-91" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-91"><a href="http://mustidev.beproductive.dk/e-mail/">E-mail</a></li>
<li id="menu-item-90" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-90"><a href="http://mustidev.beproductive.dk/driftstatus/">Driftstatus</a></li>
<li id="menu-item-92" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-92"><a href="http://mustidev.beproductive.dk/forside/">Forside</a></li>
<li id="menu-item-94" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-94"><a href="http://mustidev.beproductive.dk/handelsbetingelser/">Handelsbetingelser</a></li>
<li id="menu-item-95" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-95"><a href="http://mustidev.beproductive.dk/kontakt/">Kontakt</a></li>
<li id="menu-item-96" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-96"><a href="http://mustidev.beproductive.dk/prisoversigt/">prisoversigt</a></li>
</ul></div>                    </div>
@mustimuu you can make the ul a flex parent if you want it would be much easier to wrap all the lis in flex
I think thats what you tried to do?
mustimuu
@mustimuu
Apr 24 2018 12:04
yes !
how did you give it a extr class?
Abdus Samad
@asamad123
Apr 24 2018 12:04
i added a flexbox class use
you just add a class to it
mustimuu
@mustimuu
Apr 24 2018 12:05
yes but where
i mean
in the browser inspector?
Abdus Samad
@asamad123
Apr 24 2018 12:05
i added in the browser inspector yes
mustimuu
@mustimuu
Apr 24 2018 12:06
still doesent work
@asamad123 how did you add it?
where in the inspector?
Abdus Samad
@asamad123
Apr 24 2018 12:07
so in the main dashboard add a extra class to it
mustimuu
@mustimuu
Apr 24 2018 12:08
one second sir !
@asamad123 thank you by the way
@mustimuu thank you
@asamad123 thanks
no brownies?
Abdus Samad
@asamad123
Apr 24 2018 12:09
sad, why no brownies this if my first help :(
mustimuu
@mustimuu
Apr 24 2018 12:09
im trying
@asamad123 thank you
Abdus Samad
@asamad123
Apr 24 2018 12:09
its cool
dont worry
mustimuu
@mustimuu
Apr 24 2018 12:09
@asamad123 thanx
Abdus Samad
@asamad123
Apr 24 2018 12:09
hahah
mustimuu
@mustimuu
Apr 24 2018 12:10
:D
sir
i want to wrap it all around a di
trying in the inspector but i cant?
Abdus Samad
@asamad123
Apr 24 2018 12:11
check you pm inbox i messaged you
mustimuu
@mustimuu
Apr 24 2018 12:11
i can edit the classes
kk
Abdus Samad
@asamad123
Apr 24 2018 12:12
you got it
mustimuu
@mustimuu
Apr 24 2018 13:13
Can someone help me ?
Tom
@moT01
Apr 24 2018 13:24
whats the problem
@mustimuu
mustimuu
@mustimuu
Apr 24 2018 13:25
I gave the container a container-fluid in the inspector
But now i want to save it, but where? im working in wordpress
there is not HTMl file
like where do i save those
Tom
@moT01
Apr 24 2018 13:27
im not sure how wordpress works
no html file, ...so what is there
mustimuu
@mustimuu
Apr 24 2018 13:29
like alot of things
i open the files in cyberduck
or filezilla
Tom
@moT01
Apr 24 2018 13:31
so what type of files are they
chompoo500ml
@chompoo500ml
Apr 24 2018 13:34
@mustimuu as i know, it depends on the theme you use; some theme will not allow you to modify html
Norvin Burrus
@ndburrus
Apr 24 2018 13:36
@jeffersonnnn these may be helpful: :sparkles:
Jamal Uddin
@jamal-pb95
Apr 24 2018 13:47
problem freeCodeCamp beta.JPG
When I'm trying to open freeCodeCamp Beta website . there showing me a message "Something wrong. please try again later" and the screen view is looking below:
Norvin Burrus
@ndburrus
Apr 24 2018 14:16
@dmk1111 you might like these: :sparkles:
Ken Haduch
@khaduch
Apr 24 2018 15:05
@jamal-pb95 - I'm not actually on the Beta site, but I can open it and the pages look fine for me at this time. Have you tried again?
hari
@hari983
Apr 24 2018 17:03
hello
beginner help regarding mongodb ??
it is not starting
MongoDB shell version v3.6.4
connecting to: mongodb://127.0.0.1:27017/-
2018-04-24T20:54:12.381+0400 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2018-04-24T20:54:12.382+0400 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:251:13
@(connect):1:6
Nate Mallison
@NJM8
Apr 24 2018 17:23
@hari983 how are you starting the connection?
GRIMROOT
@GRIMROOT
Apr 24 2018 17:23
@jamal-pb95 why are you using beta?
GRIMROOT
@GRIMROOT
Apr 24 2018 17:26
https://codepen.io/GRIMROOT/project/live/DNKmKk Any Suggestions... This is Html/Css Only, Unless there is simple Jquery code that can slide transition my different pages. :)
pal-crystal
@pal-crystal
Apr 24 2018 18:39
@GRIMROOT good =)
pal-crystal
@pal-crystal
Apr 24 2018 18:48
how many challenges did u finish on fcc ?
buiphuking
@buiphuking
Apr 24 2018 19:37
hi guys, who good at css help me plz!
Marouane R
@mrassili
Apr 24 2018 19:39
Hi buiphuking. What are you struggling with?
buiphuking
@buiphuking
Apr 24 2018 19:39
@mrassili
hi
i want use html and css build this menu of this website
http://tuoitre.uit.edu.vn/
but too hard with me, help me plz
Marouane R
@mrassili
Apr 24 2018 19:42
I'm actually using my phone
I will see it when I get home
In the meantime
Have you written your html code yet
LydaTech
@lydatech
Apr 24 2018 19:44
@buiphuking its a wordpress mega menu
buiphuking
@buiphuking
Apr 24 2018 19:44
@lydatech
i know, i need to build this with pure html and css
LydaTech
@lydatech
Apr 24 2018 19:45
at a minimum youll need jquery/JS too
@buiphuking what is it for?
buiphuking
@buiphuking
Apr 24 2018 19:48
@mrassili
i tried many way but i can't do that, mega menu....., then i quit
https://codepen.io/buiphuking/pen/MGyZbo
@lydatech
website for my school
Ken Haduch
@khaduch
Apr 24 2018 20:42
@buiphuking - I don't know if looking at this page will give you any ideas - there are many different implementations of CSS only menus. I had something that I used on a project once upon a time. It is certainly possible to do dropdown menus without JS, not sure if it will give any ideas how to implement the "mega menu"...
Daniel Feldman
@Feldbot
Apr 24 2018 21:33

I'm trying to set up a reusable function for tic tac toe that helps transition between options screens. I'm fading out previous html, putting in new html and trying to run a callback function that runs after the text has faded in. I'm calling the function with two arguments, where level is the html and registerLevel is an existing function: changeScreen(level, registerLevel).
The changeScreen function looks like this:

function changeScreen(html, fn) {
    $("div.gameSetup").fadeOut(500, function() {
      $("div.gameSetup").html(html).fadeIn(500);
      fn(); // How do I get the callback to execute without error?
    });
  }

The issue I am having is when I pass in fn as a variable for my function, I can't literally pass it as an executing argument, like changeScreen(level, registerLevel());, and I get a "fn is not a function" error when I try to execute it as above. So I don't understand how to execute the function as a callback when passed in as a parameter.

Daniel Feldman
@Feldbot
Apr 24 2018 21:39
@buiphuking Another resource to check out if you are looking specifically to build a mega-menu. W3 schools sometimes has many common widgets prebuilt that you can play with to see how they are constructed.
Moisés Man
@moigithub
Apr 24 2018 22:05
@Feldbot pass a function reference
without CALLING it (do not add parenthesis when pass the function )
Daniel Feldman
@Feldbot
Apr 24 2018 22:09
@moigithub That doesn't seem to work. I called like this changeScreen(level, registerLevel) (no parentheses on registerLevel). Can you show me an example of what you mean?
Moisés Man
@moigithub
Apr 24 2018 22:09
that should work
buiphuking
@buiphuking
Apr 24 2018 22:12
@khaduch
i will send you my code
@Feldbot
check my html code
Daniel Feldman
@Feldbot
Apr 24 2018 22:15
@buiphuking Can you post it to an IDE like codepen?
this is what i want
http://tuoitre.uit.edu.vn/
Daniel Feldman
@Feldbot
Apr 24 2018 22:24
@moigithub So when I pass it in, how would I execute it in my changeScreen function? fn comes through as the function definition, not an executable function. If I try to put parentheses to get it to execute in the body of my changeScreen function, like this fn(), I get an error "fn is not a function" (which it isn't). So when I assign the parentheses in the function it is looking for an actual fn function, not creating an executable function substituting fn as a parameter for my registerLevel function.
Moisés Man
@moigithub
Apr 24 2018 22:25
then check registerLevel, how u defined it
function salute(){ alert('Hello'); }
function callSalute(fn){
  fn();
}
callSalute( salute );
Daniel Feldman
@Feldbot
Apr 24 2018 22:28
@buiphuking Your pen looks like you have it. What's the problem you are having?
Moisés Man
@moigithub
Apr 24 2018 22:28
registerLevel should be a function similar to salute on the example above...
and u pass as reference.. without () like above
on the body when u add() u will execute the function reference
TonyRednil
@TonyRednil
Apr 24 2018 22:31
Hey guys, was there a simpler way I could have accomplished this?
https://www.freecodecamp.org/challenges/where-do-i-belong
Brad
@bradtaniguchi
Apr 24 2018 22:32
@TonyRednil No one can see your solution, just the challenge (and our own solution if we have on saved)
post yours with 3 backticks (left of the 1 key) above and below your code for formating
TonyRednil
@TonyRednil
Apr 24 2018 22:38

function getIndexToIns(arr, num) {
arr.sort(function(a, b) {
return a- b;
});
for (var i = 0; i < arr.length; i++) {
if (arguments[1] <= arr[i]) {
return i;
}
}
return arr.length;
}

getIndexToIns([2, 5, 10], 15);

I don't understand what you mean by the formatting @bradtaniguchi
Barbara Pentoney
@flyfishingbarbara
Apr 24 2018 22:39
hi guys...i'm still can't get this geolocation to work and after messing with it now none of my 'icons, backgrounds, etc' dont work when they used to and could only get hardcoded location....i've followed some vids and now getting super mixed up ....can someone take a look and see why my code doesn't work...thanks!! https://codepen.io/flyfishingbarbara/pen/XZoKyz?editors=0010
Moisés Man
@moigithub
Apr 24 2018 22:39
colored text with black background, and some indentation for easy reading @TonyRednil
Barbara Pentoney
@flyfishingbarbara
Apr 24 2018 22:40
@TonyRednil like this
TonyRednil
@TonyRednil
Apr 24 2018 22:41

```function getIndexToIns(arr, num) {
arr.sort(function(a, b) {
return a- b;
});
for (var i = 0; i < arr.length; i++) {
if (arguments[1] <= arr[i]) {
return i;
}
}
return arr.length;
}

getIndexToIns([2, 5, 10], 15);

Like that?
function getIndexToIns(arr, num) {
    arr.sort(function(a, b) {
    return a- b;
  });
  for (var i = 0; i < arr.length; i++) {
    if (arguments[1] <= arr[i]) {
      return i;
    }
  }
  return arr.length;
}

getIndexToIns([2, 5, 10], 15);
oh
Daniel Feldman
@Feldbot
Apr 24 2018 22:43
@moigithub Maybe you can check out my pen. I am getting the error after the click, so maybe there is something strange with my registerLevel function?
Moisés Man
@moigithub
Apr 24 2018 22:48
dont see any registerLevel function.. did u save ?
Brad
@bradtaniguchi
Apr 24 2018 22:48
@TonyRednil You probably dont need to use the arguments object if your provided only 2 arguments always. (Just use num) Also idk if you need to sort right?
Barbara Pentoney
@flyfishingbarbara
Apr 24 2018 22:48
is @cmccormack around..??
Daniel Feldman
@Feldbot
Apr 24 2018 22:49
@moigithub Sorry, I didn't save. Just did! It's the last function in the js panel.
Moisés Man
@moigithub
Apr 24 2018 22:50

@flyfishingbarbara check browser console (not codepen console)
after add a console.log

  function updateDOM(data) {
    console.log(data); <<<<<<

{error: "Please provide longitude as lon and latitude as lat as numbers/floats."}

soo next step should be check those parameters lat, lon

TonyRednil
@TonyRednil
Apr 24 2018 22:50
@bradtaniguchi I do need to sort it because not all of the inputs the website uses are in order. That's just the one that I was using at the time. I didn't even think to use num. I was wondering if I could somehow do this with a while loop.
Brad
@bradtaniguchi
Apr 24 2018 22:52
Yea you can usually do a while loop instead of for in most cases.
but that wouldn't be much "simplier" IMO
TonyRednil
@TonyRednil
Apr 24 2018 22:52
@bradtaniguchi Then what would be simpler in your opinion?
Moisés Man
@moigithub
Apr 24 2018 22:53
@flyfishingbarbara .. and u will see u have a typo
Brad
@bradtaniguchi
Apr 24 2018 22:53
I mean for the most part you code isn't too complex to start with, you can make it more functional or some other "fancier" approach which is probably some 1 line solution. But that's arguable "simplier". (I can see something with .find()probably being working)
usually when your using the for (var i=0; i< arr.length; i++) you can usually sub one of the functional operator loops, or at least for of or maybe for in
Moisés Man
@moigithub
Apr 24 2018 22:55
@Feldbot line 62
u calling changeScreen with only 1 param
soo fn is undefined
Brad
@bradtaniguchi
Apr 24 2018 22:55
(don't use for in in this case tho, just FWI)
TonyRednil
@TonyRednil
Apr 24 2018 22:55
@bradtaniguchi I haven't been taught .find() yet... You're going over stuff that freecodecamp hasn't taught me yet...
Brad
@bradtaniguchi
Apr 24 2018 22:56
@TonyRednil Idk if FCC even teaches it off the top of my head, I never liked the for(blah) loop in angular language and always try to use alternatives. But that's just me
TonyRednil
@TonyRednil
Apr 24 2018 22:57
@bradtaniguchi where can I learn these alternatives? also could I potentially just put num into arr, sort, and then use:
```
return arr.indexOf(num);
Brad
@bradtaniguchi
Apr 24 2018 22:57
@TonyRednil https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find MDN is a great resource to find out whats out there
Barbara Pentoney
@flyfishingbarbara
Apr 24 2018 22:57
@moigithub ...omg!! all because i misspelled 'longitude'...?? criminy!! thanks for catching that!! arghhhh!
Brad
@bradtaniguchi
Apr 24 2018 22:58
@TonyRednil yea you could, but most of the time you have the index of the loop iteration your in, so indexOf is doing like "extra" work ya know?
TonyRednil
@TonyRednil
Apr 24 2018 22:58
Not really... @.@
Brad
@bradtaniguchi
Apr 24 2018 22:59
I mean if anything, less key-types ;D
TonyRednil
@TonyRednil
Apr 24 2018 23:00
@bradtaniguchi true lol. I'm just still really new to figuring all this coding stuff out...
Brad
@bradtaniguchi
Apr 24 2018 23:00
Yea, especially with JS there's like 5 ways todo most things. (Its a flexible language) and all of them basically do the same thing.
Daniel Feldman
@Feldbot
Apr 24 2018 23:01
@moigithub Thanks Moisés you nailed it. Ugh been stuck on that for hours, lol!
Abhilash Kumar
@apravink
Apr 24 2018 23:02
Has anyone built the sinon game using react?
TonyRednil
@TonyRednil
Apr 24 2018 23:02
@bradtaniguchi what would be your most recommended approach to teaching yourself how to code?
Brad
@bradtaniguchi
Apr 24 2018 23:02
@TonyRednil But id consider all those other alternatives to be "surgar" for the same stuff.
Thomas Tylek
@zippkidd
Apr 24 2018 23:03
I've seen some website designs using white or clear borders in lieu of margins. Anyone know why that might be?
Brad
@bradtaniguchi
Apr 24 2018 23:04
@TonyRednil I believe in learning through doing. Also you get more "programming" experience with javascript if you focus on node. Less to consider about html+css+dom, which is nice and all, but does little to teach you about programming, if you know what I mean.
Barbara Pentoney
@flyfishingbarbara
Apr 24 2018 23:04
@moigithub thanks again!
Brad
@bradtaniguchi
Apr 24 2018 23:04
You can learn alot with node + console.log ;D
Moisés Man
@moigithub
Apr 24 2018 23:04
:+1:
Barbara Pentoney
@flyfishingbarbara
Apr 24 2018 23:04
vives en peru?
Moisés Man
@moigithub
Apr 24 2018 23:05
si
Brad
@bradtaniguchi
Apr 24 2018 23:06
But I mean if your planning on being a front-end dev, knowing all the html+css+dom stuff is important so you can't neglect that, but none of that is core "programming" per-say
Barbara Pentoney
@flyfishingbarbara
Apr 24 2018 23:07
pues 'saludos' desde san diego...
TonyRednil
@TonyRednil
Apr 24 2018 23:08
Ok, now this is weird. For the exact same problem I tried:
```
```
function getIndexToIns(arr, num) {
arr = arr.push(num);
arr.sort(function(a, b) {
return a - b;
});
return arr.indexOf(num);
}
getIndexToIns([2, 5, 10], 15);
Daniel Feldman
@Feldbot
Apr 24 2018 23:10
@moigithub Y un ¡grande gracias! de Colorado :-)
TonyRednil
@TonyRednil
Apr 24 2018 23:11
and it returned "TypeError: arr.sort is not a function" but all of my conditions are checked.....
Brad
@bradtaniguchi
Apr 24 2018 23:12
@TonyRednil The return value of arr.push()is the new length of the array, not the array (wtf right?)
Plus, doing var copyOfArray = arrdoesn't do what you expect either, the two variables still point to the same array (the variables have the same original reference)
Barbara Pentoney
@flyfishingbarbara
Apr 24 2018 23:12
@Feldbot ...that's funny... hey denver - my sister lives out there...also some great fly fishing...
TonyRednil
@TonyRednil
Apr 24 2018 23:13
ok I just removed the arr = and now it is going through
```
function getIndexToIns(arr, num) {
  arr.push(num);  
  arr.sort(function(a, b) {
    return a - b;
  });
  return arr.indexOf(num);
}
getIndexToIns([2, 5, 10], 15);
I'm still confused as to why that happened....
Daniel Feldman
@Feldbot
Apr 24 2018 23:15
@flyfishingbarbara Suave! It would be nice to have Baja in your backyard, love that place! :-)
Brad
@bradtaniguchi
Apr 24 2018 23:15
@TonyRednil Idk how come your tests went through, since technically your code isn't runnable and crashes when you tried to use the sort function
Barbara Pentoney
@flyfishingbarbara
Apr 24 2018 23:16
:smile:
TonyRednil
@TonyRednil
Apr 24 2018 23:24
what makes it even weirder is that if I put "arr =" in front of either arr.push or arr.sort I get the "TypeError: arr.sort is not a function"
Brad
@bradtaniguchi
Apr 24 2018 23:28
@TonyRednil arr = arr.sort(/*stuff*/)should be valid, its uneccessary, but valid
Stephen James
@sjames1958gm
Apr 24 2018 23:28
@TonyRednil well, arr.push returns a number, so the next call to arr.sort arr is not an array anymore
Brad
@bradtaniguchi
Apr 24 2018 23:29
^
TonyRednil
@TonyRednil
Apr 24 2018 23:30
@sjames1958gm so wait..... arr = arr.push(num); would set arr = num; not whatever arr was only with num on the end of the array?
Brad
@bradtaniguchi
Apr 24 2018 23:30
@TonyRednil Yes
Stephen James
@sjames1958gm
Apr 24 2018 23:30
@TonyRednil No, it is actually the new length of the array, but not an array anymore :(
Brad
@bradtaniguchi
Apr 24 2018 23:30
@TonyRednil The return value of arr.push()is the new length of the array, not the array (wtf right?)
TonyRednil
@TonyRednil
Apr 24 2018 23:31
ok now I get it....
Thomas Tylek
@zippkidd
Apr 24 2018 23:33
Is there any benefit to using white/clear borders instead of margins? I've seen some web designer portfolios that do that
Smootimus
@Smootimus
Apr 24 2018 23:52
:)