12 lines
385 B
JavaScript
12 lines
385 B
JavaScript
const express = require('express');
|
|
const router = express.Router();
|
|
|
|
router.post('/', (req, res) => {
|
|
const { input } = req.body;
|
|
if (!Array.isArray(input) || input.length === 0)
|
|
return res.status(400).json({ error: 'input must be a non-empty array' });
|
|
res.json({ ret: input.reduce((acc, n) => acc + Number(n), 0) / input.length });
|
|
});
|
|
|
|
module.exports = router;
|