Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #25444

Re: I need help with the following code.

Newsgroups comp.lang.javascript
Subject Re: I need help with the following code.
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References <cb3a7a8c-b4b5-4cce-8184-ebfdaf9a9d8b@googlegroups.com> <XnsA36EC3A863756eejj99@194.109.133.133> <4fcfff57-3b7e-47fe-bc56-f006d847d652@googlegroups.com>
Date 2014-07-18 19:51 +0200
Message-ID <XnsA36ECA0CCD17Deejj99@194.109.133.133> (permalink)

Show all headers | View raw


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)

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

I need help with the following code. Iria Vasquez-Paez <iriavp@gmail.com> - 2014-07-18 09:39 -0700
  Re: I need help with the following code. Tim Streater <timstreater@greenbee.net> - 2014-07-18 18:07 +0100
  Re: I need help with the following code. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-07-18 19:14 +0200
    Re: I need help with the following code. Iria Vasquez-Paez <iriavp@gmail.com> - 2014-07-18 10:28 -0700
      Re: I need help with the following code. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-07-18 19:51 +0200
        Re: I need help with the following code. Iria Vasquez-Paez <iriavp@gmail.com> - 2014-07-18 11:24 -0700
          Re: I need help with the following code. Tim Streater <timstreater@greenbee.net> - 2014-07-18 20:06 +0100
            Re: I need help with the following code. Iria Vasquez-Paez <iriavp@gmail.com> - 2014-07-18 12:27 -0700
              Re: I need help with the following code. Iria Vasquez-Paez <iriavp@gmail.com> - 2014-07-18 12:47 -0700
              Re: I need help with the following code. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-07-18 21:30 +0100
                Re: I need help with the following code. Iria Vasquez-Paez <iriavp@gmail.com> - 2014-07-18 14:41 -0700
                Re: I need help with the following code. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-07-18 23:28 +0100
                Re: I need help with the following code. Iria Vasquez-Paez <iriavp@gmail.com> - 2014-07-18 16:54 -0700
                Re: I need help with the following code. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-07-19 01:57 +0100
                Re: I need help with the following code. Mike Duffy <md_002@videotron.ca> - 2014-07-18 21:29 -0400
                Re: I need help with the following code. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-07-19 03:00 +0100
                Re: I need help with the following code. Gene Wirchenko <genew@telus.net> - 2014-07-21 10:23 -0700
                Re: I need help with the following code. Tim Streater <timstreater@greenbee.net> - 2014-07-19 09:11 +0100
              Re: I need help with the following code. Tim Streater <timstreater@greenbee.net> - 2014-07-18 21:33 +0100
          Re: I need help with the following code. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-07-18 22:06 +0200
  Re: I need help with the following code. Iria Vasquez-Paez <iriavp@gmail.com> - 2014-07-18 10:23 -0700
    Re: I need help with the following code. Tim Streater <timstreater@greenbee.net> - 2014-07-18 18:27 +0100
  Re: I need help with the following code. danca <cyberdanny@tiscalinet.it> - 2014-07-18 22:04 +0200
    Re: I need help with the following code. danca <cyberdanny@tiscalinet.it> - 2014-07-18 22:53 +0200
      Re: I need help with the following code. danca <cyberdanny@tiscalinet.it> - 2014-07-18 22:56 +0200
      Re: I need help with the following code. Tim Streater <timstreater@greenbee.net> - 2014-07-18 22:08 +0100
        Re: I need help with the following code. danca <cyberdanny@tiscalinet.it> - 2014-07-18 23:37 +0200
          Re: I need help with the following code. John Harris <niam@jghnorth.org.uk.invalid> - 2014-07-20 10:50 +0100
            Re: I need help with the following code. danca <cyberdanny@tiscalinet.it> - 2014-07-20 20:56 +0200
              Re: I need help with the following code. Tim Streater <timstreater@greenbee.net> - 2014-07-20 22:40 +0100
                Re: I need help with the following code. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-07-21 07:41 +0200
              Re: I need help with the following code. Scott Sauyet <scott.sauyet@gmail.com> - 2014-07-21 11:49 -0700
                Re: I need help with the following code. danca <cyberdanny@tiscalinet.it> - 2014-07-22 13:58 +0200
                Re: I need help with the following code. Scott Sauyet <scott.sauyet@gmail.com> - 2014-07-22 07:45 -0700
                Re: I need help with the following code. danca <cyberdanny@tiscalinet.it> - 2014-07-22 21:54 +0200
      Re: I need help with the following code. Iria Vasquez-Paez <iriavp@gmail.com> - 2014-07-18 14:42 -0700
        Re: I need help with the following code. danca <cyberdanny@tiscalinet.it> - 2014-07-19 00:00 +0200
          Re: I need help with the following code. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-07-18 23:42 +0100
  Re: I need help with the following code. Denis McMahon <denismfmcmahon@gmail.com> - 2014-07-18 21:12 +0000

csiph-web