-2
I created a function that takes a value and adds 10% on top of the value.
The question is:
- I want that if the user enters a value equal to or less than 100 it adds 10%. Now if the value is greater than 100 it adds 15%.
Take the example:
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: false}))
const porcentagem = parseFloat (10/100)
const calculaImpost = (valor) => {
return parseFloat(valor * porcentagem)
}
app.post('/calcular', (req, res) => {
res.json({
imposto: calculaImpost(req.body.valor)
})
})
app.listen(3000, (req, res) => {
console.log('Server is Running')
})
show!!! Thank you very much!!!
– Sena Oliveira