目次
Math.random()
Math.round(数値)
Math.ceil(数値)
Math.floor(数値)
1. Math.random()
⇨0~1までのランダムの数値を作成します。
console.log(Math.random()) #出力結果 0.04764646236311276
1. Math.round(数値)
⇨四捨五入する
console.log(Math.round(1.6)) #出力結果2
Math.ceil(数値)
⇨対象の数値の小数点以下を切り上げ
console.log(Math.ceil(1.4)); #結果2
Math.floor(数値)
⇨対象の数値の小数点以下を切り捨てます
console.log(Math.floor(1.6)); // 1.6を切り捨て、1となる