-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.js
36 lines (30 loc) · 907 Bytes
/
routes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const express = require('express');
const router = express.Router();
router.get('/add/:num1/:num2', function (req, res) {
let num1 = parseInt(req.params.num1)
let num2 = parseInt(req.params.num2)
let sum = (num1 + num2).toString()
res.json(sum)
})
router.get('/subtract/:num1/:num2', function (req, res) {
// TODO
let num1 = parseInt(req.params.num1)
let num2 = parseInt(req.params.num2)
let result = (num1 - num2).toString()
res.json(result)
})
router.get('/multiply/:num1/:num2', function (req, res) {
// TODO
let num1 = parseInt(req.params.num1)
let num2 = parseInt(req.params.num2)
let result = (num1 * num2).toString()
res.json(result)
})
router.get('/divide/:num1/:num2', function (req, res) {
// TODO
let num1 = parseInt(req.params.num1)
let num2 = parseInt(req.params.num2)
let result = (num1 / num2).toString()
res.json(result)
})
module.exports = router