Git Product home page Git Product logo

food-chart's Introduction

Food Data Processing Code

This is a JavaScript code that processes food data from a JSON file (food.json) and provides various functionalities to list and sort the food items based on different criteria.

How to Use

  1. Clone the repository or download the food.json files to your local machine.

  2. Ensure that you have the food.json file in the same directory as your JavaScript code.

  3. Open the JavaScript code file (assuming it's named foodApp.js) in a text editor or IDE.

  4. Run the code using a JavaScript runtime or environment that supports the console.log function.

  5. The code will list all the food items and perform various operations like sorting by protein content, carb content, listing food items in specific categories, and filtering food items by calorie content.

Functions

The code provides the following functions:

  1. listAllFoodItems(data): Lists all the food items.

  2. listFoodItemsByCategory(data, category): Lists all the food items in a specific category.

  3. listAllFoodItemsByCalorie(data, above): Lists all the food items with calorie above or below a given threshold (100).

  4. listAllFoodItemsByProtien(data): Lists all the food items sorted by the highest protein content to the lowest.

  5. listAllFoodItemsByCab(data): Lists all the food items sorted by the lowest carb content to the highest.

Example Output

The code, when executed, will display the following output (assuming foodData contains the JSON data from food.json):

All Food Items:
[ 'Apple', 'Banana', 'Chicken Breast', ... ]

Vegetables:
[ 'Carrot', 'Broccoli', 'Spinach', ... ]

Fruits:
[ 'Apple', 'Banana', 'Orange', ... ]

Proteins:
[ 'Chicken Breast', 'Salmon', 'Tofu', ... ]

Nuts:
[ 'Almonds', 'Walnuts', 'Peanuts', ... ]

Grains:
[ 'Rice', 'Quinoa', 'Oats', ... ]

Dairy:
[ 'Milk', 'Cheese', 'Yogurt', ... ]

Food Items with Calorie Above 100:
[ 'Peanuts', 'Cheese', 'Salmon', ... ]

Food Items with Calorie Below 100:
[ 'Apple', 'Banana', 'Carrot', ... ]

Food Items Sorted by Highest Protein Content:
[ 'Salmon', 'Chicken Breast', 'Tofu', ... ]

Food Items Sorted by Lowest Carb Content:
[ 'Salmon', 'Chicken Breast', 'Tofu', ... ]

Note

Make sure to have the food.json file in the same directory as the JavaScript code. The code reads data from this JSON file for processing.

Happy food data processing!

food-chart's People

Contributors

sukomal07 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.