[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

I need help with the following code.

Iria Vasquez-Paez

7/18/2014 4:40:00 PM

This is the code as it starts on Code Academy.com. I'd greatly appreciate help on this.

var bool = true;

while(bool === true){
console.log("Less is more!");
bool = false;
}


You have to remove the equals signs.

var bool = true;

while(bool = true){
console.log("Less is more!");
bool = false;
}


This is my solution that does't pass the editor.


var bool = true;
while(bool) {
console.log ("Less is more!";
bool = false;
}


This solution is a problem with syntax. Other solutions cause my browser to crash. I need to solve this headache in order to move on. I have gone ahead but I am not progressing with this problem. I really need a solution. The above solution is a syntax problem. Thanks.


Iria
40 Answers

ram

7/18/2014 4:55:00 PM

0

Iria Vasquez-Paez <iriavp@gmail.com> writes:
>var bool = true;
>while(bool === true){
> console.log("Less is more!");
> bool = false;
>}

>You have to remove the equals signs.

What I get when I remove the equals signs is:

var bool true;
while(bool true){
console.log("Less is more!");
bool false;
}

This has nothing to do with JavaScript.

It's about English. It's about the meaning of the English
words »remove« and the compound »equals signs« and the
phrase »to remove the equals signs«.

>This is my solution that does't pass the editor.

When one has to do something, there is no »solution«, there
is an »outcome«. A »problem« has a solution, an action has
an »outcome«. »Remove the equals signs« is not a problem,
it's a calling for an action.

I have shown above what the outcome of a removal of the
equals signs is. And another calling, problem or question
was not given.

Tim Streater

7/18/2014 5:08:00 PM

0

In article <cb3a7a8c-b4b5-4cce-8184-ebfdaf9a9d8b@googlegroups.com>,
Iria Vasquez-Paez <iriavp@gmail.com> wrote:

> This is the code as it starts on Code Academy.com. I'd greatly appreciate
> help on this.
>
> var bool = true;
>
> while(bool === true){
> console.log("Less is more!");
> bool = false;
> }
>
>
> You have to remove the equals signs.
>
> var bool = true;
>
> while(bool = true){
> console.log("Less is more!");
> bool = false;
> }
>
>
> This is my solution that does't pass the editor.
>
>
> var bool = true;
> while(bool) {
> console.log ("Less is more!";
> bool = false;
> }
>
>
> This solution is a problem with syntax. Other solutions cause my browser to
> crash. I need to solve this headache in order to move on. I have gone ahead
> but I am not progressing with this problem. I really need a solution. The
> above solution is a syntax problem. Thanks.

Reading this I am puzzled as to what question you are asking. You have
3 sets of code, although it is unclear what problem has been set and by
whom.

First set of code looks like it will put one line of output to the
console, and could in fact be simplified down to one statement - the
console.log statement.

Second set of code looks like it will likely loop for ever, as you are
setting bool to true at the top of the while.

Third set will give a syntax error because you're missing a closing
paren after the double-quote.

What I've written may or may not be relevant or even true as I've not
run any of the code examples. But then you've not specified your
problem or what you're trying to do.

--
"I am enclosing two tickets to the first night of my new play; bring a
friend.... if you have one." - GB Shaw to Churchill "Cannot possibly
attend first night, will attend second... if there is one." - Winston
Churchill, in response.

Evertjan.

7/18/2014 5:14:00 PM

0

Iria Vasquez-Paez <iriavp@gmail.com> wrote on 18 jul 2014 in
comp.lang.javascript:

> This is the code as it starts on Code Academy.com. I'd greatly
> appreciate help on this.
>
> var bool = true;
>
> while(bool === true){
> console.log("Less is more!");
> bool = false;
>}

This is nonsense code as it can be reduced to

var bool = true;
console.log("Less is more!");
bool = false;

which can be reduced to:

var bool = false;
console.log("Less is more!");

> You have to remove the equals signs.

Why? [I don't take commands from strangers.]

> var bool = true;
>
> while(bool = true){
> console.log("Less is more!");
> bool = false;
>}

same result, can be reduced to:

var bool = false;
console.log("Less is more!");

> This is my solution that does't pass the editor.

You probably mean something else than an editor,
as an editor just edits a textfile and passes all texts.

> var bool = true;
> while(bool) {
> console.log ("Less is more!";
> bool = false;
>}

missing closing ")" in line 3, should be:

console.log ("Less is more!");

> This solution is a problem with syntax.

It is not a solution,
as solution means your problem is gone.

> Other solutions cause my browser to crash.

Undoubtedly you can make other syntax mistakes,
and mistakenly call tham a solution.

But I doubt syntax errors in JS crash a modern browser,
probably it just freezes them when you make a endless loop,
and should warn you after a timeout.

But there always are countless "other solutions" that are not syntax errors.

> I need to solve this headache in order to move on.

Paracetamol?

> I have gone ahead but I am not progressing with this problem.

Impossible as "progressing" and "going ahead" just mean the same.

> I really need a
> solution. The above solution is a syntax problem. Thanks

You don't ask for anything here, so why the "thanks"?

A syntax error is not a solution.

You don't even tell what you want your code to do,
and your examples do nothing.

Perhaps, dear Iria, you could restart and tell us
what you want your code to do.

Or is it your teacher giving you homework?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Iria Vasquez-Paez

7/18/2014 5:24:00 PM

0

On Friday, July 18, 2014 9:39:57 AM UTC-7, Iria Vasquez-Paez wrote:
> This is the code as it starts on Code Academy.com. I'd greatly appreciate help on this.
>
>
>
> var bool = true;
>
>
>
> while(bool === true){
>
> console.log("Less is more!");
>
> bool = false;
>
> }
>
>
>
>
>
> You have to remove the equals signs.
>
>
>
> var bool = true;
>
>
>
> while(bool = true){
>
> console.log("Less is more!");
>
> bool = false;
>
> }
>
>
>
>
>
> This is my solution that does't pass the editor.
>
>
>
>
>
> var bool = true;
>
> while(bool) {
>
> console.log ("Less is more!";
>
> bool = false;
>
> }
>
>
>
>
>
> This solution is a problem with syntax. Other solutions cause my browser to crash. I need to solve this headache in order to move on. I have gone ahead but I am not progressing with this problem. I really need a solution. The above solution is a syntax problem. Thanks.
>
>
>
>
>
> Iria



It should read

var bool = true;
while(bool) {
console.log ("Less is more!");
bool = false;
}

Tim Streater

7/18/2014 5:28:00 PM

0

In article <d5a1defa-92c0-4519-b30c-1d9a9a639c94@googlegroups.com>,
Iria Vasquez-Paez <iriavp@gmail.com> wrote:

> It should read
>
> var bool = true;
> while(bool) {
> console.log ("Less is more!");
> bool = false;
> }

Yes? So what? My questions still stand.

--
"Once you adopt the unix paradigm, the variants cease to be a problem - you
bitch, of course, but that's because bitching is fun, unlike M$ OS's, where
bitching is required to keep your head from exploding." - S Stremler in afc

Iria Vasquez-Paez

7/18/2014 5:28:00 PM

0

On Friday, July 18, 2014 10:14:02 AM UTC-7, Evertjan. wrote:
> Iria Vasquez-Paez <iriavp@gmail.com> wrote on 18 jul 2014 in
>
> comp.lang.javascript:
>
>
>
> > This is the code as it starts on Code Academy.com. I'd greatly
>
> > appreciate help on this.
>
> >
>
> > var bool = true;
>
> >
>
> > while(bool === true){
>
> > console.log("Less is more!");
>
> > bool = false;
>
> >}
>
>
>
> This is nonsense code as it can be reduced to
>
>
>
> var bool = true;
>
> console.log("Less is more!");
>
> bool = false;
>
>
>
> which can be reduced to:
>
>
>
> var bool = false;
>
> console.log("Less is more!");
>
>
>
> > You have to remove the equals signs.
>
>
>
> Why? [I don't take commands from strangers.]
>
>
>
> > var bool = true;
>
> >
>
> > while(bool = true){
>
> > console.log("Less is more!");
>
> > bool = false;
>
> >}
>
>
>
> same result, can be reduced to:
>
>
>
> var bool = false;
>
> console.log("Less is more!");
>
>
>
> > This is my solution that does't pass the editor.
>
>
>
> You probably mean something else than an editor,
>
> as an editor just edits a textfile and passes all texts.
>
>
>
> > var bool = true;
>
> > while(bool) {
>
> > console.log ("Less is more!";
>
> > bool = false;
>
> >}
>
>
>
> missing closing ")" in line 3, should be:
>
>
>
> console.log ("Less is more!");
>
>
>
> > This solution is a problem with syntax.
>
>
>
> It is not a solution,
>
> as solution means your problem is gone.
>
>
>
> > Other solutions cause my browser to crash.
>
>
>
> Undoubtedly you can make other syntax mistakes,
>
> and mistakenly call tham a solution.
>
>
>
> But I doubt syntax errors in JS crash a modern browser,
>
> probably it just freezes them when you make a endless loop,
>
> and should warn you after a timeout.
>
>
>
> But there always are countless "other solutions" that are not syntax errors.
>
>
>
> > I need to solve this headache in order to move on.
>
>
>
> Paracetamol?
>
>
>
> > I have gone ahead but I am not progressing with this problem.
>
>
>
> Impossible as "progressing" and "going ahead" just mean the same.
>
>
>
> > I really need a
>
> > solution. The above solution is a syntax problem. Thanks
>
>
>
> You don't ask for anything here, so why the "thanks"?
>
>
>
> A syntax error is not a solution.
>
>
>
> You don't even tell what you want your code to do,
>
> and your examples do nothing.
>
>
>
> Perhaps, dear Iria, you could restart and tell us
>
> what you want your code to do.
>
>
>
> Or is it your teacher giving you homework?
>
>
>
> --
>
> Evertjan.
>
> The Netherlands.
>
> (Please change the x'es to dots in my emailaddress)




Evertjan, I need 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!

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!

?
Stuck? Get a hint!
Your condition Your condition should only be:

while(bool)





Do the instructions make more sense to everybody now that I've posted it? Thanks for the responses so far. I am asking for a full-blown solution. Yes I know I have an infinite loop. The question is how to resolve the infinite loop. Thanks,



Iria

Evertjan.

7/18/2014 5:52:00 PM

0

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)

Iria Vasquez-Paez

7/18/2014 6:25:00 PM

0

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.

Tim Streater

7/18/2014 7:07:00 PM

0

In article <53f9d880-6794-4ad6-a219-1276e3df41d9@googlegroups.com>,
Iria Vasquez-Paez <iriavp@gmail.com> wrote:

> On Friday, July 18, 2014 10:51:44 AM UTC-7, Evertjan. wrote:

> > The question remains:
> >
> > "What do you want your code to do?"

> Thanks but that solution, however matching in brevity, doesn't work in the
> editor.

What editor? And what does an editor have to do with anything? Your
javascript is executed by a *browser*. Which one are you using?

--
"Once you adopt the unix paradigm, the variants cease to be a problem - you
bitch, of course, but that's because bitching is fun, unlike M$ OS's, where
bitching is required to keep your head from exploding." - S Stremler in afc

Iria Vasquez-Paez

7/18/2014 7:28:00 PM

0

On Friday, July 18, 2014 12:06:35 PM UTC-7, Tim Streater wrote:
> In article <53f9d880-6794-4ad6-a219-1276e3df41d9@googlegroups.com>,
>
> Iria Vasquez-Paez <iriavp@gmail.com> wrote:
>
>
>
> > On Friday, July 18, 2014 10:51:44 AM UTC-7, Evertjan. wrote:
>
>
>
> > > The question remains:
>
> > >
>
> > > "What do you want your code to do?"
>
>
>
> > Thanks but that solution, however matching in brevity, doesn't work in the
>
> > editor.
>
>
>
> What editor? And what does an editor have to do with anything? Your
>
> javascript is executed by a *browser*. Which one are you using?
>
>
>
> --
>
> "Once you adopt the unix paradigm, the variants cease to be a problem - you
>
> bitch, of course, but that's because bitching is fun, unlike M$ OS's, where
>
> bitching is required to keep your head from exploding." - S Stremler in afc

My browser is Chrome. No solution I have tried is working. I have tried many solutions. I have no idea what will work yet.


According to the website this is the solution:

var bool = true;

while(bool){
console.log("Less is more!");
bool = false;
}


You want to run a loop saying Less is more and end it. The browser freezes up with any code I write into it.


Iria