Skip to content

Instantly share code, notes, and snippets.

@yangjunjun
Last active December 26, 2015 07:19
Show Gist options
  • Save yangjunjun/7113956 to your computer and use it in GitHub Desktop.
Save yangjunjun/7113956 to your computer and use it in GitHub Desktop.
这段代码的本意是生成一个随机的三位数,而且这个三位数不能够同时相同,但是代码却有一个错误;正确的代码应该是把第八行代码去掉,改成第九行代码。
function getRandomInt() {
var max = 999;
var min = 100;
var result = Math.floor(Math.random() * (max - min + 1) + min)
var num_arr = (result + '').split('');
var isEqual = (num_arr[0] == num_arr[1]) ? ((num_arr[1] == num_arr[2]) ? true : false) : false;
if (isEqual) {
numRand(); //error
// result = numRand();
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment