divide number with decimals javascript

前端 未结 8 2050
误落风尘
误落风尘 2021-01-03 12:54

how can I divide number (money) to x number equally the number could be with one or two decimal or without it

such as 1000 or 100.2 or

8条回答
  •  时光说笑
    2021-01-03 13:46

    
    
    function myFunction(number,divide) {
            var money = number / divide;
            money = Math.ceil(money * 100) / 100;
            alert(money);   //1285.34
        }
    

    http://jsbin.com/ucuFuLa

提交回复
热议问题