Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
Christine de la Fuente
@xtine88
hello guys
Lee
@LeeConnelly12
@xtine88 hello
Ken Haduch
@khaduch
@xtine88 hello - what's happening?
Christine de la Fuente
@xtine88
i don't understand the Factorilization of the Numbers algorithm
I semi got the answer...but it doesnt make sense to me...can someone explain it?
Ken Haduch
@khaduch
@xtine88 - could you post your code?
Christine de la Fuente
@xtine88
yes sir
Screen Shot 2017-10-29 at 2.57.28 AM.png
Ken Haduch
@khaduch
and any specific questions, too!
Christine de la Fuente
@xtine88
I understand the for loop
however, I don't understand why I need to set var x = 1
Ken Haduch
@khaduch
@xtine88 - one thing that you are not doing is returning the final value - console.log doesn't return the value. then...
Christine de la Fuente
@xtine88
oh yes, I just put console log...to print it in the command line to test out
other wise I wouldn't see it
Ken Haduch
@khaduch

@xtine88 - the definition of 0! is that it is equal to 1. If the incoming value is 0 your loop will never run, so the value will remain at 1 and that is what you want to return. That's the main reason.

And to complete the function you have to actually do return x; after the loop, at the same place you have console.log(x);

Christine de la Fuente
@xtine88
what's the difference between return x and console.log(x)? isn't console.log(x) the same as a return x only that its printing it?
would you say that "var x = 1" is just a way to enter the loop?
Ken Haduch
@khaduch

@xtine88 - no, console.log(x) doesn't return a value from the function, it might return a value (probably a meaningless one) to the place where you called console.log, but for all intents and purposes, it doesn't return a value. Especially not from the function. You can leave it there for debug purposes, but you have to have an explicit return x; otherwise you get an implicit return undefined;

And you could look at var x = 1; as a way to enter the loop - initializing the value, but since it isn't really a loop-control value, maybe it's not technically correct to call it anything having to do with entering the loop. Basically I would just think of it as initialization of the variable. And if you do no further computation to modify the variable, that will be the final answer.

Lance LeBlanc
@LucarLeo
Hi, I'm on the tribute page for the basic front end and am having issues with properly centering my lists
Ken Haduch
@khaduch
@LucarLeo - is your page on CodePen - want to post your URL, if it is?
Lee
@LeeConnelly12
@LucarLeo try putting all of the list items in one ul
<ul style="list-style: none;">
            <li class="list-txt">What does she do?</li>
            <li class="list-txt">Sits on a guy's shoulder. </li>
            <li class="list-txt">does angry lala noises </li>
            <li class="list-txt">trusts you </li>
            <li class="list-txt">What she doesn't do:
            <li class="list-txt">tall people that isn't her personal portable chair </li>
            <li class="list-txt"> tall people who don't pet her before speaking</li>
            <li class="list-txt"> tall people who look down at her</li>
        </ul>
Ken Haduch
@khaduch
@LucarLeo I don't see lists on your page? Oh, wait, you changed the styling... Centering lists like that doesn't work if you want the list to be left-justified (like a normal list view.)
One way to do it is to set up a bootstrap grid row and pick a central set of columns to contain the data of your list. There might be other ways to do it, too -
Lee
@LeeConnelly12
@LucarLeo Also, you're missing an end div tag in your html just above your lists
<div class="nano-bg">
    <h1 class="brnz-text">Nanamo Ul Namo</h1>
    <h5 class="brnz-txt"> the ultimate cinnamon roll</h5>
    <img class="smaller-img img-center" src="http://chrysaliswiki.wdfiles.com/local--files/people:nanamo-ul-namo/nanamoulnamo_ff14.png"
        alt="a cute angry lalafell"></img>
    </>
Ken Haduch
@khaduch
@LucarLeo - on codepen, all of the CSS should be in the CSS panel, for correct usage of codepen.
Lance LeBlanc
@LucarLeo
I'm just getting back into coding in general, so all of this is still a bit newish
Ken Haduch
@khaduch

@LucarLeo - one thing that you can do, to center the lists without the center-justification, is to use flex. For example, wrap the two divs that you have your lists with another div, and on that parent div, add a class like class="flex-center" and in your CSS panel, define .flex-center like this:

.flex-center {
    display: flex;
    flex-direction: column;
    align-items: center;
}

See if that gives you the effect that you are looking for?

Ken Haduch
@khaduch
@LucarLeo - I neglected to mention that I commented out the text-align: center; from your .list-txt class declaration.
@LucarLeo - the screenshot of what it looks like with those settings (just the central portion of the screen)
image.png
Lance LeBlanc
@LucarLeo
I think the part I was trying to say (which the misunderstanding is on my part) is that I wanted to keep it as the format it was in, but trying to get it to move more center without having to take it out of <ul>
situation.JPG
Ken Haduch
@khaduch
@LucarLeo - it might be better to take it out of the <ul> and just use <p> tags for each item? I'm going to try that - I see what you are having problems with, there is some built-in margin or padding in the list to separate the text from the bullet. Or just use a <div> to wrap each line - that eliminates the baggage of the <ul> and the <li>. The first four lines in this next screen shot are structured that way.
image.png
Amin
@hanamin
Hey guys, I need some help. I'm working on the simon says front end project and am trying to loop through an array that contains the sequence of colors. This loop adds a class that represents the color lighting up, then should remove the class so the color goes dim again. However, my colors never go dim. Can anyone tell me what's wrong?
for(var i = 0; i <= sequence.length; i++){
$("#" + sequence[i]).addClass('brightLight');
setTimeout(function(){
$("#" + sequence[i]).removeClass('brightLight');
}, 1000);
}
}
For reference, here's the codepen link. If you try hitting start, you'll see what I mean
Ken Haduch
@khaduch
@sunorei - the problem is that the for loop will run through without regard to the timeout values - and at the end of the timeout, the value for i will be 1 beyond the end of the array, so it will not access anything. One thing to try first is instead of using var i try using let i - that changes the behavior of the value within the loop. It still won't work properly as far as the sequence of events, but I think that it might make the class be removed at the end.
Amin
@hanamin
Hmm ok I'll have to consider it. On a side note, is there a benefit to use let over var? From what I understand the only difference is scope, correct?
The course didn't cover let at all iirc
Lee
@LeeConnelly12
@sunorei You can't re declare let variables
in the same scope anyway
Amin
@hanamin
Sorry I'm still in the learning phases, is it safer for it to be that way?
like prevents error or something similar?
Ken Haduch
@khaduch
@sunorei @LeeConnelly12 - http://wesbos.com/for-of-es6/ - this shows that you can use let in a for loop. You cannot use const in a loop, but you can use let - take a look at that page that I linked it is showing the same type of issue that you have in your simon pen.
Lee
@LeeConnelly12
@khaduch Shows you can what? you can't re declare the same let variable in the same block scope?
@sunorei I think it is best practice to use const for variables you're not going to change the value of.
And use let for variables that you may need to change the value of.
Ken Haduch
@khaduch
The other thing that you need to do is to increase the timeout value for each successive call to setTimeout because all of the calls are essentially started at the same time. So for the first setTimeout, you would want to use 1000, for the second, 2000 - that would sequence them at roughly 1 second apart.
but they would still all have the colors set to their bright intensity at the same time... You need a different way to sequence the replay of the buttons.