is1to20 = str => /^(?:[1-9]|1[0-9]|20)$/.test(str); // 测试: new Array(20) .join(' ') .split(' ') .map((_,i)=>i+1) .forEach(_=>console.log(_, is1to20(_.toString())))