# 章序号/节序号/节/笔记序号 codecademy, Condition # 概念阐释 # 举例子 # 类比、比较与对比 # 问题 [RaceDay](https://www.codecademy.com/courses/introduction-to-javascript/projects/race-day) As a timeline, registration would look like this:![registration-timeline](https://content.codecademy.com/projects/introduction-to-javascript/learn-javascript-control-flow/race-day/raceday-timeline.svg) Here’s how our registration works. There are **adult runners (over 18 years of age)** and **youth runners (under 18 years of age)**. They can register **early or late**. Runners are assigned a race number and start time based on their age and registration. Race number: - **Early adults** receive a race number **at or above 1000**. - **All others** receive a number below 1000. Start time: - **Adult** registrants run at 9:30 am **or** 11:00 am. - **Early adults** run at 9:30 am. - **Late adults** run at 11:00 am. - **Youth** registrants run at 12:30 pm (regardless of registration). But we didn’t plan for runners that are exactly 18! We’ll handle that by the end of the project. # 问题答案 [codecademy](https://www.codecademy.com/courses/introduction-to-javascript/projects/race-day) ```js let raceNumber = Math.floor(Math.random()*1001); let registerEarly=true; let runnerAge= 18; //满足准时报道的成年人,发放1000以上的号码,改变race number的变量 if(registerEarly===true && runnerAge>18){ raceNumber+=1000; }; //准时报道的成年人,在9:30开始比赛 if(registerEarly===true && runnerAge>18 ){ console.log('race will begin at 9:30, and your race number is ' + raceNumber);//这里的raceNumber符合上面的if条件 }else if(registerEarly===false && runnerAge>18){ console.log('race will begin at 11:30, and your race number is '+ raceNumber);//因为在前面已经创建了条件,必须是18岁以上早到的成年人才会满足random number+1000,否则为random number,1000以下 }else if(runnerAge < 18){ console.log('youth will begin at 12:00, and your race number is '+ raceNumber); }else{ console.log('Please approach the registration desk,thanks!') }//只剩下=18这个条件了 ``` # 备注(经验集/错误集) - 重要的是把可能的条件先列清楚