Giter Site home page Giter Site logo

suzanovini / bmi-calcutator Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3.22 MB

Body mass index calculator

License: MIT License

HTML 19.68% JavaScript 40.09% CSS 40.23%
javascript js json language-javascript language-json linguagem-javascript bmi bmi-calculator calculator css

bmi-calcutator's Introduction

BMI-calcutator

Creating a body mass index calculator

homer weight

About this project

The BMI calculator is basically a tool that divides the weight by the square of height of an individual to measure its body mass so that it can indicate its weight category, although it is not a diagnose of body fatness.

Why?

This project is part os my pernonal portifolio, I'm a begginer program developer and I intend to study at Kwantlen Polytechnic University in Canada, so I'll be happy if you could provide me any feedback about the project, code structure or anything that you can report that could make me a better developer!

Email-me: [email protected]

Connect with me at linkedin

You can also use this project as you wish!

Software Requirements

-Visual Studio Code (VSCode) download VSCode

-Live Server extension in VSCode

-A browser of your choice (I used Opera GX) download Opera GX

Step by Step

The first step to create the BMI calculator was to open a new folder in Visual Studio Code to group all of the program’s files. It was then created a reference list file for all weight categories in JSON (JavaScript Object Notation) named as listing.js.

listing

The second step was to create a interaction screen for the user, named index.html, therefore it had to be writen a HTML code to “draw” this screen.

index

This file contains coding that creates labels to type the gender, weight and height information, show the results value, the calulate button and a reference link to a css file. It also contains a script code to bring an external script file to it, wich in this case is the searchcategory.js file. The HTML file tells the searchCategory.JS to the the following operations:

  1. Recieve the iformation the user typed and verify if it is not empty;
  2. Convert it to allow the BMI calculus, if those are not empty;
  3. Calcutale it;
  4. Search the category the user fits in using the BMI value generated;
  5. Once the script has found the category it will show the results in HTML page.

Since it is a web page and it was not created a data server, an extension named LiveServer in VSCode had to be downloaded so that the web browser could interpret that the data is storaged in a server, that is essencial for a request to work.

Live Server

Obs.: It always has to be opened with a live server to work.

Next step was to create the Javascript file named “searchCategory.js” to get the information from the JSON file “listing.js” and bring it to the calculator so that it can tell wich weight category the individual fits in.

JSON is a notation, in other words, it is the format of the data we are processing. This file is reponsable for validating the typed information and convert it when the user clicks the button “Calculate BMI” for the calculus to be done A command that starts “translating” JSON to a known format, an array in this case, is JSON.parse and it works like this:

JSON.parse(variable) The variable is the content in JASON format. In this case the code is inside the variable “answer”. To run trought the elements of a vector it is used a loop estructure called “for Each”: var categories = JSON.parse(answer);

    categories.forEach(function(category) {
        console.log(category);
    });

The command will run throught the various categories in listing.js file and print the resulting vectors in console.

It had also to be added value conditions to match the information contained in listing.js using the “if... else” command followed by an error alert for the user to know the input value is not acceptable.

The searchCategory.js file now looks like this:

searchCategory

It was then created a css file, named as styles.css to add some style to the web page. css image

After creating all the four files (Listing.js, Index.html, searchCategory.js and styles.css) and opening the HTML file with a live server the calculator is finaly working!

page layout

bmi-calcutator's People

Contributors

suzanovini 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.