diff --git "a/\345\210\230\346\242\205\347\220\263/\344\275\234\344\270\232/1.js" "b/\345\210\230\346\242\205\347\220\263/\344\275\234\344\270\232/1.js" new file mode 100644 index 0000000000000000000000000000000000000000..7d62849ec7aae2099422ae0775ac9b9ad821745b --- /dev/null +++ "b/\345\210\230\346\242\205\347\220\263/\344\275\234\344\270\232/1.js" @@ -0,0 +1,34 @@ +let l= /^[0-9]+[0-9]*/ +let obj={ + jia: function(a,b){ + if(!l.test(a)||!l.test(b)){ + console.log("输入错误") + }else{ + return a+b; + } + }, + jian: function(a,b){ + if(!l.test(a)||!l.test(b)){ + console.log("输入错误") + }else{ + return a-b; + } + }, + cheng: function(a,b){ + if(!l.test(a)||!l.test(b)){ + console.log("输入错误") + }else{ + return a*b ; + } + }, + chu: function(a,b){ + var k= /^[1-9]+[0-9]*/; + if(!k.test(a)||!k.test(b)){ + console.log("输入错误,不能为零") + + }else{ + return a/b; + } + } +} +module.exports = obj; diff --git "a/\345\210\230\346\242\205\347\220\263/\344\275\234\344\270\232/2.js" "b/\345\210\230\346\242\205\347\220\263/\344\275\234\344\270\232/2.js" new file mode 100644 index 0000000000000000000000000000000000000000..885c61ea1613b3b3978ffc87686d78e9cac52169 --- /dev/null +++ "b/\345\210\230\346\242\205\347\220\263/\344\275\234\344\270\232/2.js" @@ -0,0 +1,5 @@ +let rr = require("./1.js"); +console.log(rr.jia(2,2)); +console.log(rr.jian(10,1)); +console.log(rr.cheng(1,20)); +console.log(rr.chu(15,3)); \ No newline at end of file