编写代码,询问用户一周内每天发送的信件数,并在控制台的javascript中显示一周内发送的信件总数
var day = 1;
var totalletters = 0; //total letters sent
for (day; day <= 7; day++) {
var getletters = 0;
getletters = prompt("Please enter the number of total letters sent today", );
totalletters += getletters;
}
console.log(totalletters); //displaying the total number of letters sent at the end of the week
// The console is showing the output as string instead of adding up the numbers
https://stackoverflow.com/questions/52884858
复制相似问题