javascript - 每 10 个芒果去除 1 个芒果

标签 javascript math

我想知道是否有人有计算每 10 的公式。因为我已经有了删除 1 的公式:

var mango = 20
var a = mango / 10
var result = mango - a

但是如果mango = 6 il仍在计算。

最佳答案

您只需要integer part计算的一部分,因为规则规定每 10 个只有一个。

var mango = 25,
    a = Math.floor(mango / 10), // get only the integer part of calculation
    result = mango - a;

console.log(result);

every 1 month remove 2.5% of the price to the price

var price = 100,
    days = 100,
    month = Math.floor(days / 30),
    result = price - price * (2.5 * month) / 100;

console.log(result);

关于javascript - 每 10 个芒果去除 1 个芒果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39056279/

相关文章:

javascript - 如何在Advance Custom Field的中继器的每个循环中显示不同的值

math - 计算 UID 可能性的大小

javascript - 使用 jquery 在选中/未选中的复选框上添加/删除值

c++ - 为什么幂函数通常计算为对数?

javascript - 将项目数组拆分为 N 个数组

javascript - 我在 nginx 中安装了一个 SSL 证书,但在浏览器中写入 url 告诉我 : ERR_CONNECTION_REFUSED

c# - 从 asp.net 中的代码隐藏函数调用 Javascript

java - 有效地计算乘积 a * b² * c³ ...

php - 分享按钮对网页性能的影响

php - 使用 XMLhttpRequest 加载的页面上的复选框