Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function catDiet(input) {
- let fats = Number(input[0]);
- let proteins = Number(input[1]);
- let carbohydrates = Number(input[2]);
- let calories = Number(input[3]);
- let water = Number(input[4]);
- let caloriesPerGram = (100 - water) * (calories / (calories * fats / 9 + calories * proteins / 4 + calories * carbohydrates / 4));
- console.log(`${caloriesPerGram.toFixed(4)}`);
- }
- Taрикатско решение:)
- function catDiet(input) {
- console.log(`${((100 - Number(input[4])) * (Number(input[3]) / (Number(input[3]) * Number(input[0]) / 9
- + Number(input[3]) * Number(input[1]) / 4 + Number(input[3]) * Number(input[2]) / 4))).toFixed(4)}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement