描述:从右手大拇指数数,从1开始,至小拇指后颠倒顺序至大拇指,至大拇指后颠倒顺序至小拇指,请问第n次后第几根手指
function findN(num){
let stack = [1,2,3,4,5,4,3,2]; //[] 1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5 4 3 2 1 2
// 解法1 找规律
let index = num % 8;
let returnVal = stack[index - 1];
return returnVal;
}
console.log(findN(1314))