??????????????bool???????????
?????е?????????д?????bool?????????????????磺
????1 var getProduct = function(finished) {
????2     if(finished){
????3     }
????4     else{
????5     }
????6 }
????7
????8 // ????
????9 getProduct(true);
???????????????????????????????getProduct(true)????????????true??????????????????????????????????????????????????????ζ????????????????????????????????????????????????????
??????1???????????????????????????getFinishedProduct??getUnFinishedProduct
??????2????bool???????????????getProduct(ProductStatus)
?????????????????
???????????????????????????????п??????????bug??????????????????ú?????????????????????
??????????????????????????????????????????????á?
????????????????????????????????????
?????????????????????
?????????????????????????????????????飬??????????????????????е????????????????????????ú????????????
??????д??????
??????????????????????????????????????????????????????????????????????д???Щ????????
?????????????????
?????е??????????????????????????е????????????????????磺
????1 var calculateTotalPrice = function()  {
????2     var roomCount = getRoomCount();
????3     var mealCount = getMealCount();
????4
????5     var roomPrice = getRoomPrice(roomCount);
????6     var mealPrice = getMealPrice(mealCount);
????7
????8     return roomPrice + mealPrice;
????9 }
??????δ????????????????????????????????????
??????δ???????????????????????????????????????????????????????????????????????????????????????????????????????????????£????????????????????????????????λ?????????????????????????λ?á???????????????????????????????????????????????????????????????????á????????????????????????????????????????????????????£?
????1 var calculateTotalPrice = function()  {
????2     var roomCount = getRoomCount();
????3     var roomPrice = getRoomPrice(roomCount);
????4
????5     var mealCount = getMealCount();
????6     var mealPrice = getMealPrice(mealCount);
????7
????8     return roomPrice + mealPrice;
????9 }
?????????????????????????????????????????????????????????????
??????????????????
??????????дif??switch??for???????е??????????д?????if??for????????????????????????????3??????????????????????????t????????????????ò??????2?????????????????Щ????????????????
????if???????????
???????if??????????е????飬???????????????????????
????1?????????????????????
???????????????????????????????????????y??????????????λ??????????????????????
????1 if(condition1) {
????2     if(condition2){
????3         if(condition3){
????4         }
????5         else{
????6             return;
????7         }
????8     }
????9     else{
????10         return;
????11     }
????12 }
????13 else {
????14     return;
????15 }
??????δ?????if????????3????????????????????????????????return???????????
????1 if(!condition1){
????2     return;
????3 }
????4 if(!condition2){
????5     return;
????6 }
????7 if(!condition3){
????8     return;
????9 }
????10 //doSth
??????δ????У??????condition1????false????????????棬?????????????????????if??????????????if?????????????????
??????????????£?????дif?????????true?????д????棬??????????????????????????????????????????????if???????
????2????????if????switch???
????????????????????????????е??????????ж?????????д???if-elseif???????????????鷳?????????????????????????????????if??????????????????????鷳??????????????????????????????????????????Ч????if????????????????????????????????
????1 if(condition == “case1”){
????2     return 1;
????3 }
????4 elseif(condition == “case2”){
????5     return 2;
????6 }
????7 elseif(condition == “case3”){
????8     return 3;
????9 }
????10 elseif(condition == “case4”){
????11     return 4;
????12 }
??????δ??????????ж???????????????????????????????????????????if?????????????????????????????????δ???????????????????Map??Dictionary????????????????????????
????1 var map = {
????2     "case1":1??
????3     "case2":2??
????4     "case3":3??
????5     "case4":4
????6 }
????7 return map[condition];
???????map???????????????????????????????????????????????
?????????????????????????ж??????????????????????漰?????????????????????????????????18?£????????????????
????3??????????????????????е???
???????????????????????????????????????μ?????У???????ú???????????????????????
????for?????????
????for???????????if?????????????????????????鷳??????????????????????
????1???????????for??????
????2??????????????o?????
????3??????????????????λ?????????????i??j??k?????????????????о???????
???????????????????廯
?????е?????????д???Щ?????????????????????????????????????????????????????????θ???????????
????1 if (age > 18 && gender == "man") {
????2     //doSth
????3 }
??????δ??????????????18??????????????????doSth????????????????????????????????
????1 var canDoSth = function (age?? gender){
????2     return age > 18 && gender == "man";
????3 }
????4 ...
????5 ...
????6 ...
????7 if(canDoSth(age?? gender)){
????8     //doSth
????9 }
???????????????????????????????????????廯???
???????
?????????????????????????????????????д????????????????α?д?????????????????????????????????????????????????п???????????????????????????????????????????????
????1????????????????????
????2??????????????????
????3???????????????????20?У??????20??????????????????????????
????4?????????
?????????????????????????????飬??????н????????????????????