學習如何在 JavaScript 中刪除數字的小數部分。
您可以使用 Math.trunc() 方法刪除數字中的小數:
Math.trunc()
let x = Math.trunc(8.7512356); // 8
親自試一試
參考手冊:JavaScript Math.trunc() 方法