侃侃尔雅
如果有N个问题,那么构建一个N维数组,通过查表计算arr[select_1][select_2][select_3][]...[select_n]来获得结果。比如你的题目有2个问题,那么就构建一个二维数组,预先存储一个表。赋值阶段可以区分一下数组是不是足够酥松如果酥松的话就把有值的地方赋好就行了:vararr=Array(2);arr[0]=Array(10);arr[1]=Array(10);arr[0][0]="123"arr[3][4]="123123"arr[5][10]="21312"functionshowAnswerForSelects(){returnarr[arguments[0]][arguments[1]];}showAnswerForSelects(3,4)->"123123"showAnswerForSelects(7,5)->undefined或者数据比较酥松,还可以构建一个switch逻辑,像这样:functionshowAnswerForSelects(){varstr=arguments[0]+"-"+arguments[1];switch(str){case"0-1":return"123";case"3-4":return"123123";case"5-10":return"21312";default:returnnull;}}调用还是一样的方式。如果比较密,那么就用字面量的方式直接赋值吧:vararr=[["123123","12312","123123"..."234134"],["123123","12312","123123"..."234134"],["123123","12312","123123"..."234134"],["123123","12312","123123"..."234134"],["123123","12312","123123"..."234134"],["123123","12312","123123"..."234134"],["123123","12312","123123"..."234134"],["123123","12312","123123"..."234134"],["123123","12312","123123"..."234134"],["123123","12312","123123"..."234134"]];functionshowAnswerForSelects(){returnarr[arguments[0]][arguments[1]];}嫌不好索引还可以用@kikong的对象字面量的方式来做。