T
T
Toster7772018-03-26 16:22:11
JavaScript
Toster777, 2018-03-26 16:22:11

How to implement such a calculator in js?

Hello,
I have a simple code:

<input type="text" value="100" placeholder="Введите вес продукта">
<ul>
<li>Белки: 23 гр</li>
<li>Жиры: 1,9 гр</li>
<li>Углеводы: 0,4 гр</li>
<li>Калории: 113 ккал</li>
</ul>

How can I make the calculator calculate the amount of calories, proteins, fats and carbohydrates based on the weight of the product entered in the input? Standard value: 100 grams

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2018-03-26
@Stalker_RED

https://jsfiddle.net/deadvf29/
Instead of Math.random, you need to substitute some formulas or tables by which values ​​are calculated.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question