Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. ///function
  2. function checker(recipe) {
  3. let counter = 0;
  4. for (let j = 0; j < quantity; j++) {
  5. for (const property in recipe.ingredient) {
  6.  
  7. let currentPropertyValue = recipe.ingredient[property];
  8. let propertyValueInMicroElementObject = microElementsObject[property];
  9.  
  10. if (propertyValueInMicroElementObject == NaN) {
  11. return `Error: not enough ${property} in stock`;
  12. }
  13. else if (propertyValueInMicroElementObject > currentPropertyValue) {
  14. microElementsObject[property] -= currentPropertyValue;
  15. counter++;
  16. }
  17. }
  18. let ingredients = Object.keys(apple.ingredient);
  19. let countOfIngredients = ingredients.length;
  20. if (counter == countOfIngredients) {
  21. return 'Success';
  22. }
  23. }
  24. }
  25.  
  26.  
  27. if (command === 'prepare') {
  28. let recipe = currentCommand[1];
  29. let quantity = Number(currentCommand[2]);
  30.  
  31. if (recipe === 'apple') {
  32. function checker(recipe);
  33.  
  34. } else if (recipe === 'lemonade') {
  35. let checker = checker(recipe);
  36. } else if (recipe === 'burger') {
  37. let checker = checker(recipe);
  38. } else if (recipe === 'eggs') {
  39. let checker = checker(recipe);
  40. } else if (recipe === 'turkey') {
  41. let checker = checker(recipe);
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement