Embark on a coding journey that will demystify the intricacies of web development with our comprehensive tutorial, "Creating a BMI Calculator Using JavaScript." Whether you're a novice in the realm of programming or an enthusiast seeking to augment your JavaScript skills, this step-by-step guide promises to be an illuminating experience. To kick off our journey, we'll delve into the fundamental building blocks of web development—HTML, CSS, and JavaScript. This tutorial caters to individuals ranging from absolute beginners to those looking to fortify their existing skill set. By providing a holistic understanding of these essential languages, participants can lay a solid foundation for their future endeavors in the dynamic field of web development.
As we progress through the tutorial, we'll focus extensively on JavaScript, unraveling its intricacies in a manner accessible to beginners. The comprehensive nature of this tutorial makes it an ideal starting point for those keen on grasping the basics of JavaScript programming. Each step is accompanied by detailed explanations, ensuring that even individuals with minimal coding experience can follow along seamlessly. The core of our tutorial centers around the creation of a Body Mass Index (BMI) calculator using JavaScript. This practical project serves as a real-world application of the concepts covered, allowing participants to witness the tangible results of their coding efforts. The BMI calculator isn't just a generic implementation—it is customized to cater to both men and women, showcasing the versatility of JavaScript in addressing diverse user needs.
A crucial aspect of this tutorial is the comprehensive walkthrough of the JavaScript code. Participants will have the opportunity to follow along with the complete code, dissecting each line to understand its purpose and contribution to the overall functionality of the BMI calculator. This hands-on approach ensures that learners not only grasp theoretical concepts but also gain practical experience in coding.
As we progress, we'll explore the principles of responsive design, ensuring that the BMI calculator is not only functional but also visually appealing across various devices. This aspect is crucial in the contemporary landscape, where users access applications on a myriad of platforms, ranging from desktops to smartphones. Understanding responsive design principles equips participants with the skills to create user-friendly interfaces that adapt seamlessly to different screen sizes. This tutorial caters to a diverse audience. For beginners, it serves as an excellent introduction to the world of programming, offering a gentle learning curve that instills confidence. For those with some programming experience, the tutorial provides an opportunity to delve deeper into JavaScript, gaining insights into its application in web development.
Beyond the immediate project of creating a BMI calculator, this tutorial aims to instill a broader understanding of programming possibilities. By grasping the fundamentals of JavaScript, HTML, and CSS, participants gain the foundational knowledge needed to explore more complex projects and venture into advanced areas of web development. Don't miss out on this exciting coding adventure. Whether you're looking to learn JavaScript, delve into web development, or embark on your first coding project, this tutorial offers a wealth of knowledge and hands-on experience. Follow along, ask questions, and witness the transformation of code into a functional BMI calculator. The skills acquired in this tutorial will undoubtedly pave the way for future coding endeavors, empowering you to navigate the dynamic world of web development with confidence and proficiency.
bmi.html
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kalkulator BMI</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="form-container">
<h2>BMI Calculator</h2>
<form id="bmi-form">
<div class="input-ctr">
<input type="number" id="weight" placeholder="Your Weight (Kg)" required>
<input type="number" id="height" placeholder="Your Height (Cm)" required>
</div>
<div class="btn-container">
<button id="btnCalc" type="button" onclick="calculateBMI()">
Calculate
</button>
<button id="btnClr" type="button" onclick="clearInput()">
Clear
</button>
</div>
</form>
</div>
<div id="result"></div>
<script src="script.js"></script>
</body>
</html>
style.css
body{
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
letter-spacing: 1.5px;
display: flex;
align-items: center;
flex-direction: column;
}
h2{
color: white;
font-size: 35px;
}
.form-container{
display: flex;
align-items: center;
flex-direction: column;
width: 25%;
margin: 250px auto 0;
padding: 30px 40px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
background-color: #3e71b3;
}
.input-ctr{
width: 400px;
display: flex;
align-items: center;
flex-direction: column;
gap: 20px;
}
::placeholder{
font-size: 25px;
font-style: italic;
color: white;
}
input[type="number"]{
font-size: 25px;
color: white;
width: 100%;
padding: 20px;
border: none;
border-radius: 5px;
background-color: #5f96df;
}
.btn-container{
text-align: center;
margin-top: 20px;
}
button{
margin: 10px;
padding: 15px 25px;
color: #fff;
border: none;
border-radius:5px;
cursor: pointer;
font-size: 25px;
letter-spacing: 1px;
font-weight: 600;
}
#btnCalc{
background-color: rgb(64, 220, 119);
}
#btnClr{
background-color: rgb(252, 54, 97);
}
#result{
margin-top: 50px;
width: 100%;
text-align: center;
}
p{
padding: 0;
margin-top: 0;
font-size: 20px;
font-weight: bold;
letter-spacing: 0.2;
}
.obesity{
color: rgb(247,74,74);
font-size: 50px;
}
.overweight{
color: rgb(255, 179, 0);
font-size: 50px;
}
.normal{
color: rgb(37, 140, 37);
font-size: 50px;
}
.underweight{
color: rgb(92, 97, 92);
font-size: 50px;
}
script.js function calculateBMI(){
var weight = parseFloat(document.getElementById('weight').value);
var height = parseFloat(document.getElementById('height').value)/100;
var bmi = weight / (height * height);
var category;
if (bmi < 18.5){
category = 'Underweight';
}else if (bmi >= 18.5 && bmi < 24.9){
category = 'Normal';
}else if (bmi >= 25 && bmi < 29.9){
category = 'Overweight';
}else{
category = 'Obesity';
}
var result = document.getElementById('result');
result.innerHTML = 'Your BMI is ' + bmi.toFixed(2) + '
' + category + '
';
}
function clearInput(){
document.getElementById('weight').value = '';
document.getElementById('height').value = '';
var result = document.getElementById('result');
result.innerHTML = '';
}
WATCH FULL VIDEO HERE!
Comments
Post a Comment