gpt4 book ai didi

javascript - 我的功能不起作用(周末)

转载 作者:行者123 更新时间:2023-12-03 09:46:03 27 4
gpt4 key购买 nike

有人可以帮我解决这个问题吗?当填写周五、周六或周日时,需要返回"is",而在所有其他情况下,则需要返回“否”。每次它都以“JA”结尾......

代码:

    // Nieuwe Array aanmaken dagen
var d = new Date();
var days = ["Zondag","Maandag","Dinsdag","Woensdag","Donderdag","Vrijdag","Zaterdag"];
d.getDay();

// Prompt welke dag
var dag = prompt('Welke dag is het vandaag?');

//functies

function isHetAlWeekend (days, dag)
{
if ( dag === days[0] || dag === days[5])
{
console.log('JA');
}
else
{
console.log('NEE');
}

}

最佳答案

它工作正常,测试 ZondagVrijdagZaterdag,你会得到 JA,否则 NEE

    // Nieuwe Array aanmaken dagen
var d = new Date();
var days = ["Zondag","Maandag","Dinsdag","Woensdag","Donderdag","Vrijdag","Zaterdag"];
d.getDay();

// Prompt welke dag
var dag = prompt('Welke dag is het vandaag?');

//functies

function isHetAlWeekend (days, dag)
{
if ( dag === days[0] || dag === days[5] || dag === days[6])
{
alert('JA');
}
else
{
alert('NEE');
}

}

isHetAlWeekend(days, dag);

关于javascript - 我的功能不起作用(周末),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31029813/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com