Advertisement
Spocoman

Cat Diet

Jan 7th, 2022 (edited)
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function catDiet(input) {
  2.     let fats = Number(input[0]);
  3.     let proteins = Number(input[1]);
  4.     let carbohydrates = Number(input[2]);
  5.     let calories = Number(input[3]);
  6.     let water = Number(input[4]);
  7.  
  8.     let caloriesPerGram = (100 - water) * (calories / (calories * fats / 9 + calories * proteins / 4 + calories * carbohydrates / 4));
  9.     console.log(`${caloriesPerGram.toFixed(4)}`);
  10. }
  11.  
  12.  
  13. Taрикатско решение:)
  14.  
  15. function catDiet(input) {
  16.  
  17.     console.log(`${((100 - Number(input[4])) * (Number(input[3]) / (Number(input[3]) * Number(input[0]) / 9
  18.         + Number(input[3]) * Number(input[1]) / 4 + Number(input[3]) * Number(input[2]) / 4))).toFixed(4)}`);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement