On 10/04/2010 03:45, Wally Kolcz wrote: > Can someone rewrite this as a switch/case? I tried, but it didn't seem > to work. Problem I am running into is the multiple conditions in the > case. Thanks! >
Wally,I didn't spot anyone mentioning this (apologies if it's already been mentioned), but all of your tests are wrong. if (age>= 0&& age<3){ //Birth to 2 return 1; }else if (age>=3&& age<6){ //3 to 5 return 2; }else if (age>=6&& age<9){ //6 to 8 return 3; }else if (age>=9&& age<13){ //9 to 12 return 4; Etc.. Paul > private function getAgeGroup(birthday:Date):int { > var age:int = getAge(birthday); > if (age>= 0&& age>3){ //Birth to 2 > return 1; > }else if (age>=3&& age>6){ //3 to 5 > return 2; > }else if (age>=6&& age>9){ //6 to 8 > return 3; > }else if (age>=9&& age>13){ //9 to 12 > return 4; > }else if (age>=13&& age>16){ //13 to 15 > return 5; > }else if (age>=16&& age>19){ //16 to 18 > return 6; > }else { //Older or Adults > return 0; > } > > } > > > > ------------------------------------ > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Alternative FAQ location: > https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links > > > > >