Iria Vasquez-Paez
7/18/2014 6:25:00 PM
On Friday, July 18, 2014 10:51:44 AM UTC-7, Evertjan. wrote:
> Iria Vasquez-Paez <iriavp@gmail.com> wrote on 18 jul 2014 in
>
> comp.lang.javascript:
>
>
>
> > Evertjan, I need a solution.
>
>
>
> Shall we say you "want" a solution?
>
>
>
> > Here is the question from Code Academy.com. I really should have posted
>
> > it earlier.
>
> >
>
> > Brevity is the soul of programming
>
> > You may have noticed that when we give a variable the boolean value
>
> > true, we check that variable directly--we don't bother with ===. For
>
> > instance,
>
> >
>
> > var bool = true;
>
> > while(bool){
>
> > //Do something
>
> >}
>
> > is the same thing as
>
> >
>
> > var bool = true;
>
> > while(bool === true){
>
> > //Do something
>
> >}
>
> > but the first one is faster to type. Get in the habit of typing exactly
>
> > as much as you need to, and no more!
>
>
>
> Well, that may or may not be a good advice. Syntax is not only typing
>
> brevity, but also readability, beauty of the text, and even processor speed.
>
>
>
> > If you happen to be using numbers, as we did earlier, you could even do:
>
> >
>
> > var myNumber = 1;
>
> > while(myNumber) {
>
> > // Do something!
>
> >}
>
> > Instructions
>
> > We've written the less succinct version in the editor. Correct it to the
>
> > more elegant version!
>
>
>
> So?
>
>
>
> > Stuck? Get a hint!
>
> > Your condition Your condition should only be:
>
> >
>
> > while(bool)
>
>
>
> so?
>
>
>
> > Do the instructions make more sense to everybody now that I've posted
>
> > it? Thanks for the responses so far.
>
>
>
> No question by you yet.
>
>
>
> > I am asking for a full-blown
>
> > solution. Yes I know I have an infinite loop.
>
>
>
> Well, I did not see that code.
>
> We cannot discuss about that you do not show.
>
>
>
> Did your browser crash as you said, or not?
>
>
>
> > The question is how to resolve the infinite loop.
>
>
>
> Do away with your infinite loop, methinks.
>
>
>
> An infinite loop is stupid, but not a syntax error.
>
> Your forgetting a closing ")" however, is a syntax error.
>
>
>
> I showed you this solution,
>
> the full-blown reduction of your code:
>
>
>
> ===============
>
> var bool = false;
>
> console.log("Less is more!");
>
> ===============
>
>
>
> You see, a loop that does not look can be thrown out.
>
>
>
> ========================
>
>
>
> The question remains:
>
> "What do you want your code to do?"
>
>
>
> Showing a code that does not do what you want it to do
>
> really needs an explanation of what you want it to do,
>
> otherwise how are we ever to understand what you want?
>
>
>
> --
>
> Evertjan.
>
> The Netherlands.
>
> (Please change the x'es to dots in my emailaddress)
Thanks but that solution, however matching in brevity, doesn't work in the editor. I have to ask myself what's going on with that. It's like the editor is stuck in an infinite loop. When I leave the equals signs in, it seems to work again. But it says to remove the equals signs. So I remove the equals signs and it manages to freeze up again. I have no idea anymore, really.