diff --git "a/\345\221\250\345\277\227\346\235\260/2\346\234\21014.html" "b/\345\221\250\345\277\227\346\235\260/2\346\234\21014.html" deleted file mode 100644 index 5b741126c86c0ebe232a66dcf480bdf7c14f2f02..0000000000000000000000000000000000000000 --- "a/\345\221\250\345\277\227\346\235\260/2\346\234\21014.html" +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - 纪2023年2月14日 - - - 城南小陌又逢春,只见桃花不见人. 人有生老三千疾,唯有相思不可医. - - \ No newline at end of file diff --git "a/\346\236\227\347\217\212/\345\212\240\345\207\217\344\271\230\351\231\244/calculate.js" "b/\346\236\227\347\217\212/\345\212\240\345\207\217\344\271\230\351\231\244/calculate.js" new file mode 100644 index 0000000000000000000000000000000000000000..a3a89e15081e00cd44a25270f84943a17417dfca --- /dev/null +++ "b/\346\236\227\347\217\212/\345\212\240\345\207\217\344\271\230\351\231\244/calculate.js" @@ -0,0 +1,5 @@ +let calculate = require("./calculator"); +console.log(calculate.jia(1,2)); +console.log(calculate.jian(11,1)); +console.log(calculate.cheng(1,2)); +console.log(calculate.chu(20,2)); \ No newline at end of file diff --git "a/\346\236\227\347\217\212/\345\212\240\345\207\217\344\271\230\351\231\244/calculator.js" "b/\346\236\227\347\217\212/\345\212\240\345\207\217\344\271\230\351\231\244/calculator.js" new file mode 100644 index 0000000000000000000000000000000000000000..30d32ef3b12aba0fd1fe43d49db129f92c858f00 --- /dev/null +++ "b/\346\236\227\347\217\212/\345\212\240\345\207\217\344\271\230\351\231\244/calculator.js" @@ -0,0 +1,33 @@ +var result = /^[0-9]+[0-9]*/; +let obj = { + jia: function(a, b) { + if(!result.test(a) || !result.test(b)) { + return "输入的数为非数值类型,请重新输入"; + }else{ + return a + b; + } + }, + jian: function(a, b) { + if(!result.test(a) || !result.test(b)) { + return "输入的数为非数值类型,请重新输入"; + }else{ + return a - b; + } + }, + cheng: function(a, b) { + if(!result.test(a) || !result.test(b)) { + return "输入的数为非数值类型,请重新输入"; + }else{ + return a * b; + } + }, + chu: function(a, b) { + var res = /^[1-9]+[0-9]*/; + if(!res.test(a) || !res.test(b)) { + return "其中一个为0或非数值类型,请重新输入"; + }else{ + return a / b; + } + } +} +module.exports = obj; \ No newline at end of file