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


Groups > comp.lang.javascript > #19416 > unrolled thread

Why is this not working

Started by"Tony" <tony.johansson@inport.com>
First post2013-04-23 13:11 +0200
Last post2013-04-23 15:02 +0200
Articles 4 — 3 participants

Back to article view | Back to comp.lang.javascript


Contents

  Why is this not working "Tony" <tony.johansson@inport.com> - 2013-04-23 13:11 +0200
    Re: Why is this not working "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-04-23 14:28 +0300
    Re: Why is this not working Carlos Pedro <carlospedr@gmail.com> - 2013-04-23 05:42 -0700
      Re: Why is this not working "Tony" <tony.johansson@inport.com> - 2013-04-23 15:02 +0200

#19416 — Why is this not working

From"Tony" <tony.johansson@inport.com>
Date2013-04-23 13:11 +0200
SubjectWhy is this not working
Message-ID<kl5q2o$65h$1@dont-email.me>
This works fine 
hours++;
hours = hours < 10 ? "0" + hours : hours;
cellTitle = hours + ":" + "00";

but if I change the code to this it doesn't work
I can't see why ?
hours++;
cellTitle = hours < 10 ? "0" + hours : hours + ":" + "00";

//Tony

[toc] | [next] | [standalone]


#19417

From"Jukka K. Korpela" <jkorpela@cs.tut.fi>
Date2013-04-23 14:28 +0300
Message-ID<kl5r31$au6$1@dont-email.me>
In reply to#19416
2013-04-23 14:11, Tony wrote:

> cellTitle = hours < 10 ? "0" + hours : hours + ":" + "00";

Analyze the structure of the expression, on the basis of operator 
precedence rules as defined in the standard.

Alternatively, save some trouble and use parentheses liberally. The 
expression would be too complicated to be read comfortably without 
parentheses even if it were formally correct to omit them.

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/

[toc] | [prev] | [next] | [standalone]


#19418

FromCarlos Pedro <carlospedr@gmail.com>
Date2013-04-23 05:42 -0700
Message-ID<2c7818fb-c233-44b6-a4d0-efb2c3f5046e@googlegroups.com>
In reply to#19416
assuming you can use a browser:
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Operator_Precedence

[toc] | [prev] | [next] | [standalone]


#19419

From"Tony" <tony.johansson@inport.com>
Date2013-04-23 15:02 +0200
Message-ID<kl60k3$8dq$1@dont-email.me>
In reply to#19418

"Carlos Pedro"  wrote in message 
news:2c7818fb-c233-44b6-a4d0-efb2c3f5046e@googlegroups.com...

assuming you can use a browser:
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Operator_Precedence

cellTitle = (hours < 10 ? "0" + hours : hours) + ":00";

//Tony 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web