'How can I determine the height of a building by using JavaScript
Suppose, I want to determine the total height of a building where the first ten floors of a building: 15 feet/floor, the second ten floors: 12 feet/floor, the rest of the upper floors: 10 feet/floor. if the number of the total floors is 40, then how can I determine the total height of that building by using javascript.
Solution 1:[1]
It is a simple math.
const firstTenBlocks = 10 * 15
const secondTenBlocks = 10 * 12
const restBlocks = (40 - 20) * 10
const totalHeight = firstTenBlocks + secondTenBlocks + restBlocks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vladimir Trotsenko |
