如何使函数输出密码函数的密钥



我正在尝试创建一个页面,并使用自某个日期以来的天数作为密码。唯一有效的密码是静态的,并被"包围。我希望能够使用我天的结果作为密码。我该怎么做?

在说"if (pass1 == "abcde") {"的行上,我尝试将"abcde"更改为我的函数名称几天以来,以及我从该函数获得的最后一个变量。

function passWord() {
var testV = 1;
var pass1 = prompt('Please Enter Your Password to see deez burgerz','Password ');
while (testV < 3) {
if (!pass1) 
history.go(-1);
if (pass1 == "abcde") {
alert('Lucky guess...');
window.open('http://bowenpowell.com');
break;
} 
testV+=1;
var pass1 = 
prompt('Access Denied - Password Incorrect, ur dumb.','Password');
}
if (pass1.toLowerCase()!="password" & testV ==3) 
history.go(-1);
return " ";
} 

从那以后,我的职能已经持续了几天:

function dateFunction() {
var currentDate = new Date(),
m = currentDate.getMonth() +1,
d = currentDate.getDate(),
y = currentDate.getFullYear();
var current = y + "/" + m + "/" + d;
var date2 = '2018/9/4';
current = current.split('/');
date2 = date2.split('/');
current = new Date(current[0], current[1], current[2]);
date2 = new Date(date2[0], date2[1], date2[2]);
current_unixtime = parseInt(current.getTime() / 1000);
date2_unixtime = parseInt(date2.getTime() / 1000);
var timeDifference = current_unixtime - date2_unixtime;
var timeDifferenceInHours = timeDifference / 60 / 60;
var timeDifferenceInDays = timeDifferenceInHours  / 24 + 2;

document.getElementById("demo").innerHTML = timeDifferenceInDays;
}

我试过了

if (pass1 == timeDifferenceInDays) {
if (pass1 == dateFunction()) {
if pass1 == timeDifferenceInDays {
if pass1 == dateFunction() {
if pass1 == 'timeDifferenceInDays' {
if pass1 == 'dateFunction()' {

dateDifference()需要返回要用作密码的值。

function dateFunction() {
var currentDate = new Date(),
m = currentDate.getMonth() + 1,
d = currentDate.getDate(),
y = currentDate.getFullYear();
var current = y + "/" + m + "/" + d;
var date2 = '2018/9/4';
current = current.split('/');
date2 = date2.split('/');
current = new Date(current[0], current[1], current[2]);
date2 = new Date(date2[0], date2[1], date2[2]);
current_unixtime = parseInt(current.getTime() / 1000);
date2_unixtime = parseInt(date2.getTime() / 1000);
var timeDifference = current_unixtime - date2_unixtime;
var timeDifferenceInHours = timeDifference / 60 / 60;
var timeDifferenceInDays = timeDifferenceInHours / 24 + 2;
document.getElementById("demo").innerHTML = timeDifferenceInDays;
return timeDifferenceInDays.toString();
}

然后,您可以使用:

if (pass1 == dateFunction())