Re: Fiscal Year issue

Monday, June 2, 2014

&& and || do not group the way you think they do.
(a && b || c) === ((a && b) || c)

You've written your conditional assuming it would be (a && (b || c))

So...
var curYear = 2014;
var ListYr = "2015";
var month = "Apr";
var isTrue = (curYear == ListYr && month == "Jan" || month == "Feb" || month == "Mar" || month == "Apr" || month == "May" || month == "Jun" || month == "Jul" || month == "Aug" || month == "Sep");

isTrue evaluates to true because...

curYear == ListYr && month == "Jan" --> false
month == "Feb" --> false
month == "Mar" --> false
month == "Apr" --> true
month == "May" --> false
month == "Jun" --> false
month == "Jul" --> false
month == "Aug" --> false
month == "Sep" --> false

false || false || false || true || false || false || false || false || false -> true

You want...
(curYear == ListYr && (month == "Jan" || month == "Feb" || month == "Mar" || month == "Apr" || month == "May" || month == "Jun" || month == "Jul" || month == "Aug" || month == "Sep"))


More detail:


On Mon, Jun 2, 2014 at 11:53 AM, I.O.S <isogunro@gmail.com> wrote:
Can someone please help me with my javascript within the jsfiddle below?
I need to make sure certain dates fit within the current fiscal year (ie. Oct. 2013 - Sep. 2014)

For some reason, my script isn't working. It has (Apr. 2015) within the current fiscal year.
http://jsfiddle.net/4DFUL/12/

Thanks for any help you can provide.


--
You received this message because you are subscribed to the Google Groups "JavaScript Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javascript-information+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "JavaScript Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javascript-information+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Copyright © 2010 Web Design | Free Blogger Templates by Splashy Templates | Layout by Atomic Website Templates

Vida de bombeiro Recipes Informatica Humor Jokes Mensagens Curiosity Saude Video Games Animals Diario das Mensagens Eletronica Rei Jesus News Noticias da TV Artesanato Esportes Noticias Atuais Games Pets Career Religion Recreation Business Education Autos Academics Style Television Programming Motosport Humor News The Games Home Downs World News Internet Design Entertaimment Celebrities 1001 Games Doctor Pets Net Downs World Enter Jesus Mensagensr Android Rub Letras Dialogue cosmetics Genexus lasofia thebushrajr wingshock tripedes gorduravegetal dainfamia dejavu-transpersonal jsbenfica republicadasbadanas ruiherbon iranianforaryans eaystcheyl fotosdanadir Só Humor Curiosity Gifs Medical Female American Health Madeira Designer PPS Divertidas Estate Travel Estate Writing Computer Matilde Ocultos Matilde futebolcomnoticias girassol lettheworldturn topdigitalnet Bem amado enjohnny produceideas foodasticos cronicasdoimaginario downloadsdegraca compactandoletras newcuriosidades blogdoarmario arrozinhoii