-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
50 lines (38 loc) · 1.13 KB
/
app.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const express = require("express");
const port = process.env.PORT || 3000;
const app = express();
const date = new Date().getFullYear();
app.use(express.urlencoded({
extended: true
}));
app.use(express.static("public"))
app.set('view engine', 'ejs');
app.get("/", (req, res) => {
res.render("index", {
investment: "120,000",
returns: "112,339",
value: "232,339",
up: "1000",
uIn: "12",
uy: "10",
date: date
});
});
app.post("/", (req, res) => {
let P = req.body.msip;
let y = req.body.year
let n = (req.body.year) * 12;
let In = req.body.intrest;
let i = (req.body.intrest / 100) / 12;
let M = P * (((Math.pow(1 + i, n)) - 1) / i) * (1 + i);
M = Math.floor(M);
res.render("index", {
investment: (P * n).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","),
returns: (M - (P * n)).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","),
value: M.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","),
up: P,
uIn: In,
uy: y
});
});
app.listen(port, () => console.log(`Server is running on port ${port}`));