问题描述
我正在执行带有条件语句的学校任务。我正在尝试编写一些代码,询问用户拥有的宠物数量,然后结合答案,这将根据先前给出的值返回一个值/答案。
const dogs = prompt('How many dogs do you have?');
dogs = parseInt(dogs);
const cats = prompt('How many cats do you have?');
cats = parseInt(cats);
const otherPets = prompt('How many other pets do you have?');
otherPets = parseInt(otherPets);
const totalPets = 'dogs' + 'cats' + 'otherPets';
if (totalPets > 0){
alert('You have a total of 'totalPets'pets.');
}
else{
alert('You should probably get yourself a sloth.');
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)