Git Product home page Git Product logo

butkem-skilvul-task-tpa2-bmi-calculator's Introduction

Bootcamp Skilvul FullStack TPA2 - BMI Calculator

This is technical project assignment (TPA2) - BMI calculator from the Skilvul Bootcamp Fullstack of the Innovation Women Program 2023.

Table of contents

Overview

Specs

  1. Create a website application to calculate Body Mass Index (BMI) based on established standards.
  2. Users must input their Weight in KG.
  3. Users must input their Height in CM.
  4. The BMI formula for units in KG and CM is Weight / (Height/100)^2.
  5. The application should display the BMI status according to the following standards:
  • BMI Categories:
    • Underweight = <18.5
    • Normal weight = 18.5 โ€“ 24.9
    • Overweight = 25 โ€“ 29.9
    • Obesity = BMI of 30 or greater

Expected Result

  • Weight: 60 KG
  • Height: 167 CM BMI = 60 / (167/100)^2 BMI = 60 / (2.8) BMI = 21.5 BMI Categories: Normal

Screenshot

Design preview for the BMI-Calculator

Links

My process

Built with

  • Flexbox
  • CSS Grid
  • Vanilla Javascript

What I learned

The recap that is recorded here is basic css which I often rarely use.

  • Clear text content when input fields are clicked:
const clearFailNotif = () => failNotif.textContent = '';
weightInput.addEventListener('focus', clearFailNotif);
heightInput.addEventListener('focus', clearFailNotif);
  • Changing images based on conditions with the DOM :
if (bmi < 18.5) {
    BMIcat.textContent = 'under weight'.toUpperCase();
    ImgCat.src = ('assets/under_weight.svg')

} else if (bmi >= 18.5 && bmi <= 24.9) {
    BMIcat.textContent = 'normal weight'.toUpperCase();
    ImgCat.src = ('assets/normal_weight.svg')

} else if (bmi >= 25 && bmi <= 29.9) {
    BMIcat.textContent = 'over weight'.toUpperCase();
    ImgCat.src = ('assets/over_weight.svg')

} else {
    BMIcat.textContent = 'obesity'.toUpperCase();
    ImgCat.src = ('assets/obesity.svg')
}
  • Refrash page when invoke function :
const refreshPage = () => location.reload()
  • Nested event :
BtnCheck.addEventListener('click', (e) => {
    ...
    if (isValidInput) {
        ...
        if (BMIresult !== null) {
            ...

            BtnCheck.style.display = 'none';  
            BtnReCheck.style.display = 'inline-block'; /
            BtnReCheck.addEventListener('click', refreshPage)
        }
    }
})

Continued development

When reloading to clear the form after inspection, all elements are reloaded, including images. This will disrupt website performance if done on a large scale. Using React is one solution, but what if use vanilla JavaScript? It will be more complicated, but there, I will learn a lot of things.

Useful resources

  • CSS Grid - the easiest guide to use the grid, there is a picture of each code that will be generated, cool
  • Box Sizing - example of the impact of using box-sizing
  • Beautiful Button - provides botton styles complete with CSS

Author

butkem-skilvul-task-tpa2-bmi-calculator's People

Contributors

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