Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
CodeYourFuture
Module-JavaScript-Fundamentals
Repository navigation
Code
Issues
31
(31)
Pull requests
150
(150)
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
25fa3a3ea371c74c44b4ffc4cc0d641f66bca482
Breadcrumbs
Module-JavaScript-Fundamentals
/
Sprint-3
/
3-mandatory-implement
/
1-bmi.js
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
22 lines (15 loc) · 890 Bytes
25fa3a3
Breadcrumbs
Module-JavaScript-Fundamentals
/
Sprint-3
/
3-mandatory-implement
/
1-bmi.js
Copy path
Top
File metadata and controls
Code
Blame
22 lines (15 loc) · 890 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Below are the steps for how BMI is calculated
// The BMI calculation divides an adult's weight in kilograms (kg) by their height in metres (m) squared.
// For example, if you weigh 70kg (around 11 stone) and are 1.73m (around 5 feet 8 inches) tall, you work out your BMI by:
// squaring your height: 1.73 x 1.73 = 2.99
// dividing 70 by 2.99 = 23.41
// Your result will be displayed to 1 decimal place, for example '23.4'.
// You will need to implement a function that calculates the BMI of someone based off their weight and height
// Given someone's weight in kg and height in metres
// Then when we call this function with the weight and height
// It should return a string of their Body Mass Index to 1 decimal place
function calculateBMI(weight, height) {
let result = (weight / (height * height)).toFixed(1);
return String(result);
}
console.log(calculateBMI(81, 1.8));
You can’t perform that action at this time.