Showing
2 changed files
with
6 additions
and
6 deletions
@@ -44,11 +44,11 @@ exports.lte = (num1, num2, options) => { | @@ -44,11 +44,11 @@ exports.lte = (num1, num2, options) => { | ||
44 | * @return {[boolen]} | 44 | * @return {[boolen]} |
45 | */ | 45 | */ |
46 | exports.showStorage = (leftNumber) => { | 46 | exports.showStorage = (leftNumber) => { |
47 | - leftNumber = typeof num1 === 'number' ? leftNumber : parseFloat(leftNumber, 10); | 47 | + leftNumber = +leftNumber; |
48 | 48 | ||
49 | - if (leftNumber <= 3 && leftNumber >= 0) { | 49 | + if (leftNumber <= 3 && leftNumber > 0) { |
50 | return `仅剩${leftNumber}件`; | 50 | return `仅剩${leftNumber}件`; |
51 | - } else if (leftNumber < 0) { | 51 | + } else if (leftNumber <= 0) { |
52 | return '库存不足'; | 52 | return '库存不足'; |
53 | } | 53 | } |
54 | }; | 54 | }; |
@@ -4,11 +4,11 @@ | @@ -4,11 +4,11 @@ | ||
4 | * @return {[boolen]} | 4 | * @return {[boolen]} |
5 | */ | 5 | */ |
6 | module.exports = function(leftNumber) { | 6 | module.exports = function(leftNumber) { |
7 | - leftNumber = typeof num1 === 'number' ? leftNumber : parseFloat(leftNumber, 10); | 7 | + leftNumber = +leftNumber; |
8 | 8 | ||
9 | - if (leftNumber <= 3 && leftNumber >= 0) { | 9 | + if (leftNumber <= 3 && leftNumber > 0) { |
10 | return '仅剩' + leftNumber + '件'; | 10 | return '仅剩' + leftNumber + '件'; |
11 | - } else if (leftNumber < 0) { | 11 | + } else if (leftNumber <= 0) { |
12 | return '库存不足'; | 12 | return '库存不足'; |
13 | } | 13 | } |
14 | }; | 14 | }; |
-
Please register or login to post a comment