1
I am creating an application with Node.js, using the view engine EJS, and have a calculation of preço * quantidade
, but the result is something like 80.9999999
. Does anyone know how I can round this up using the EJS?
Follows the code:
<tbody>
<% for (let i = 0; i < items.length; i++) { %>
<tr>
<td> <%= i+1 %> </td>
<td> <a href="/produto/<%= items[i].produtoId %>"><%= items[i].nome %></a> </td>
<td> R$ <%= items[i].preco %></td>
<form method="POST">
<td> <input type="text" name="quantidade" class="form-control" value="<%= items[i].quantidade %>"> </td>
<td>R$ <%= items[i].preco * items[i].quantidade %> </td>
<td>
<input type="hidden" name="carrinhoId" value="<%= items[i]._id %>">
<input type="submit" class="btn btn-dark" value="Salvar" formaction="/carrinho/save">
<a class="btn btn-light" href="/verificar-pedido?pedido=<%= items[i]._id %>"> Pedido </a>
<input type="submit" class="btn btn-danger" value="Deletar" formaction="/carrinho/delete">
</td>
It worked dude! Thank you so much!!! mainly for having explained the operation!
– Stack