diff --git "a/\346\250\241\345\235\227/j\350\256\241\347\256\227\346\234\272.js" "b/\346\250\241\345\235\227/j\350\256\241\347\256\227\346\234\272.js" new file mode 100644 index 0000000000000000000000000000000000000000..48d8d6d0891e3c4d2b7e4b952e9a5a97cd5b7a4f --- /dev/null +++ "b/\346\250\241\345\235\227/j\350\256\241\347\256\227\346\234\272.js" @@ -0,0 +1,31 @@ +let obj={ + add:function(a,b){ + if(/^[0-9]$/.test(a),/^[0-9]$/.test(b)){ + return a+b; + }else{ + return"语法错误"; + } + }, + jian:function(a,b){ + if(/[0-9]$/.test(a)&&/[0-9]$/.test(b)){ + return a-b; + }else{ + return"语法错误"; + } + }, + cheng:function(a,b){ + if(/^[0-9]$/.test(a)&&/[0-9]$/.test(b)){ + return a*b; + }else{ + return"语法错误"; + } + }, + chu:function(a,b){ + if(/^[0-9]$/.test(a)&&/[1-9]$/.test(b)){ + return a/b; + }else{ + return"语法错误"; + } + } +} +module.exports = obj; \ No newline at end of file diff --git "a/\346\250\241\345\235\227/\346\265\213\350\257\225.js" "b/\346\250\241\345\235\227/\346\265\213\350\257\225.js" new file mode 100644 index 0000000000000000000000000000000000000000..b566c805bbf7e93d321f386793e77ceeaf6c6050 --- /dev/null +++ "b/\346\250\241\345\235\227/\346\265\213\350\257\225.js" @@ -0,0 +1,5 @@ +let result=require("./j计算机"); +console.log("加的结果为:"+result.add(13,5)); +console.log("相减的结果为:"+result.jian(-2,2)); +console.log("相乘的结果为:"+result.cheng(3,"")); +console.log("相除的结果为:"+result.chu(2,0)); \ No newline at end of file