function test(name, birth_year, current_year) {
const age = current_year - birth_year;
const response = name + " is " + age;
return response;
}
test("bob", 1954, 2015)
// 函数 test(参数1.参数2,参数3)
function test(name, birth_year, current_year) {
const age = current_year - birth_year;
const response = name + " is " + age;
return response;
}
test("bob", 1954, 2015)
// 调用函数test(传入值1,传入值2,传入值3)=>function test(name="bob", birth_year=1954, current_year=2015) {
const age = current_year - birth_year; // age = 2015 - 1954 = 61
const response = name + " is " + age; // response = bob +" is "+61 = bob is 61 // 拼接
return response; // 返回结果 response 的值
}
希望可以帮助到你!
结果是bob is 61
如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!
这是一段js代码,打开浏览器,按 f12 键,点击“控制台”或者叫“console”的 tab ,把代码拷贝粘贴上就运行结果了。望采纳。
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!