gpt4 book ai didi

javascript - 函数返回值未定义

转载 作者:行者123 更新时间:2023-11-28 03:15:38 24 4
gpt4 key购买 nike

我有这个功能:

function addressVerification() {

var del;

let addVer = $('#add_verified').val();
let maddVer = $('#madd_verified').val();

if (addVer == "yes" && maddVer == "yes") {
del = true;
} else {
del = false;
}
return del;
}

当我调用它时:

$('#add_verified').change(function(){
var ver = addressVerification();
console.info("This is the returned value from the verified address function: "+ ver);
});

它返回为“未定义”。

我做错了什么?

最佳答案

您有语法错误

function addressVerification() {
var del;
let addVer = $('#add_verified').val();
let maddVer = $('#madd_verified').val();

if (addVer == "yes" && maddVer == "yes") {
del = true;
} else {
del = false;
}
} . <----- This is closing the function, ant thus, returning undefined
return del;
}

关于javascript - 函数返回值未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59668059/

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