嗨,这是我第一次来到这里,因为我是第一次学习编码,所以我很难挣扎。 我假设当我尝试将参数传递给参数时,它会混淆,或者我可能会错过一些非常简单的东西。我在哪里遗失或失败?我只是不工作......
function adultCheck(age,name) {
if (age <= 17) {
alert("Sorry " + name ", you are not allowed to see this, you are too young.");
} else {
alert("Welcome " + name ", you are " + age " visit our lounge!");
}
}
adultCheck(15,Tami);
答案 0 :(得分:1)
您需要在函数中的+
和name
个连词周围添加age
个符号,并且应该在字符串中添加引号。像,
function adultCheck(age, name) {
if (age <= 17) {
alert("Sorry " + name + ", you are not allowed to "
+ "see this, you are too young.");
} else {
alert("Welcome " + name + ", you are " + age
+ " visit our lounge!");
}
}
adultCheck(15, 'Tami');
&#13;
答案 1 :(得分:0)
你的第二个参数应该是一个字符串,所以它需要在引号中:
adultCheck(15, "Tami");
此外,您在变量周围遗漏了几个+
符号:
function adultCheck(age, name) {
if (age <= 17) {
alert("Sorry " + name + ", you are not allowed to see this, you are too young.");
} else {
alert("Welcome " + name + ", you are " + age + " visit our lounge!");
}
}
答案 2 :(得分:0)
你也忘了在变量之后添加额外的+:&#34;&#34; +名称+&#34;&#34;