我的结果一直显示我的数字为负数而不是整数

问题描述 投票:0回答:0

我是初学者,如果我的问题没有意义,请提前原谅我。

我的结果一直显示我的数字为负数或负数而不是整数,请参阅所附的屏幕截图

My Code console log result

我的代码

const bookName = prompt(`name of book?`);
const bookPageNum = prompt(`How many pages does your book have?`);
const bookPageReadToday = prompt(`How many pages did you read today?`);
const bookDailyLimit = 10;

console.log(bookName);
console.log(bookPageNum);

const bookCalc = (a, b, c, d) => {
    if (c - d === 0 || c > d) {
        console.log(`You have read your daily limit today for your book called ${a}, Well DONE!! you have ${c - b} left to read in total`);
    } else if (b - c > 0) {
        console.log(`you still have ${c - d} pages left to read today and ${c - b} pages to read in total.`);
    } else {
        console.log(`You haven't read any pages today, you have ${d} pages left to read and ${b}.`);
    }
}

bookCalc(bookName, bookPageNum, bookPageReadToday, bookDailyLimit);type here

在我的函数中,我有几个模板文字字符串,我试图将其更改为不同的语法,例如将 ${c - b} 更改为 ${c} - ${b} 但它没有用。我怀疑这是语法问题。

javascript function variables
© www.soinside.com 2019 - 2024. All rights reserved.