封裝一個時間百分比多個數比較

wanterFun = (times)=>{
  //時間:百分比
  let warterMap = {
    6:8,
    8:22,
    10:34,
    12:57,
    14:66,
    16:85,
    18:90,
    20:95,
    22:100,  
  }
  if(times<6){
    return 0;
  }else{
    return waterMap[Math.floor(tiems/2)*2]
  }
}io

 

let {keys,vlaues,entries} = Obect;let obj = {a:1,b:2,c:3}for(let keys in obj){    console.log(keys); //a,b}for(let values in obj){    console.log(values);}for(let entries in obj) {    console.log(entries);}const water = (option,val,defaultText = "") =>{    let lists = Object.entries(option).sort((a,b)=>paseInt(b[0])-paseInt(a[0]));    for(let i=0;i<lists.length;i++){        const [value,text] = lists[i]        if(val < value) {            return defaultText = text;        }else{            break;        }    }    return defalutText }const water = (value)=>{    let option = {        50:'差',        70:'良',        80:'中'    }    return water(option,value,"優")} 
相關文章
相關標籤/搜索