-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmean_sd.js
36 lines (36 loc) · 866 Bytes
/
mean_sd.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
var express = require("express");
var bodyparser = require("body-parser");
var app = express();
app.use(bodyparser.json());
app.post("/", (req, res) => {
let isa1 = req.body.isa1;
let isa2 = req.body.isa2;
let ass = req.body.ass;
let esa = req.body.esa;
let meanValue = mean(isa1, isa2, ass, esa);
res.send(
"Mean :" +
meanValue.toString() +
"\n" +
"Standard Devation:" +
standardDevation(isa1, isa2, ass, esa, meanValue).toString()
);
});
mean = (isa1, isa2, ass, esa) => {
let sum = isa1 + isa2 + ass + esa;
return sum / 4;
};
standardDevation = (isa1, isa2, ass, esa, mean) => {
isa1 -= mean;
isa2 -= mean;
ass -= mean;
esa -= mean;
isa1 *= isa1;
isa2 *= isa2;
ass *= ass;
esa *= esa;
sum = (isa1 + isa2 + ass + esa) / 4;
return Math.sqrt(sum);
};
app.listen(3000);
console.log("server started");