<script>
var name, address, city, state, zip, birthdate , social, response1, info;
//Function call - vitalinfo prompts user 7 times
function vitalinfo() {
name = window.prompt("Please enter your name", "Example: Jane Doe");
address = window.prompt("Please enter your address", "Example: 123 Main St");
city = window.prompt("Please enter your city","Example: Punxsutawney");
state = window.prompt("Please enter your state", "Example: Pennsylvania");
zip = window.prompt("Please enter your zip","Example: 12345");
birthdate = window.prompt("Please enter your birthdate","12-29-1987");
social = window.prompt("Please enter your social security number","123-45-6789");
//end prompts
vitalinfo= window.confirm("Do you want to review the information you entered?");
if (vitalinfo == true)
{
window.alert (
"Your name is " + name + "\n" +
"Your address is " + address + "\n" +
"Your city is " + city + "\n" +
"Your state is " + state + "\n" +
"Your zip is " + state + "\n" +
"Your birth date is " + birthdate + "\n" +
"Your social security number is " + social);
}
}
我想在我的 js 中有条件,以便如果名称、地址、zip 等变量返回 null,它是空白的或完全从警报中排除。我不知道从哪里开始。