diff --git a/en/contribute/OpenHarmony-JavaScript-coding-style-guide.md b/en/contribute/OpenHarmony-JavaScript-coding-style-guide.md index f540122b839d6b685a2f97a0b064c39c83c8c4f5..ff9bc6ddcaaf7395604a2a5303cda93d06cf1d08 100755 --- a/en/contribute/OpenHarmony-JavaScript-coding-style-guide.md +++ b/en/contribute/OpenHarmony-JavaScript-coding-style-guide.md @@ -643,7 +643,7 @@ The effective solutions are as follows: 1. Use integers as much as possible because integers do not need to be rounded. -2. The native JavaScript method `Number.prototype.toFixed(digits)`,`digist` is used to indicate the number of digits after the decimal point. The exponential method is not used. If necessary, the number is rounded off. This method is used to reduce the precision of the calculation result before determining the floating-point number calculation result. The sample code is as follows: +2. The native JavaScript method `Number.prototype.toFixed(digits)`,`digits` is used to indicate the number of digits after the decimal point. The exponential method is not used. If necessary, the number is rounded off. This method is used to reduce the precision of the calculation result before determining the floating-point number calculation result. The sample code is as follows: ```javascript parseFloat(0.1 + 0.2).toFixed(1); //0.3 diff --git a/zh-cn/contribute/OpenHarmony-JavaScript-coding-style-guide.md b/zh-cn/contribute/OpenHarmony-JavaScript-coding-style-guide.md index fa308f1d22bc77cef496570be1043342c6fe5623..168183261dd57cf172ff0a2b4e5211051d0b16b5 100755 --- a/zh-cn/contribute/OpenHarmony-JavaScript-coding-style-guide.md +++ b/zh-cn/contribute/OpenHarmony-JavaScript-coding-style-guide.md @@ -643,7 +643,7 @@ console.log(sum2); // 输出:0.6。所以对于二进制浮点数,(a + b) + 1. 尽可能的采用整数值运算,因为整数在表示是不需要舍入; -2. 使用JavaScript的原生方法`Number.prototype.toFixed(digits)`,`digist`参数表示小数点后数字的个数,不使用指数法,在必要时会进行四舍五入。使用该方法,在判断浮点数运算结果前对计算结果进行精度缩小。示例代码如下所示: +2. 使用JavaScript的原生方法`Number.prototype.toFixed(digits)`,`digits`参数表示小数点后数字的个数,不使用指数法,在必要时会进行四舍五入。使用该方法,在判断浮点数运算结果前对计算结果进行精度缩小。示例代码如下所示: ```javascript parseFloat(0.1 + 0.2).toFixed(1); //0.3