官术网_书友最值得收藏!

Functions as arguments

Functions can be used as arguments for other functions. Let's use the preceding bmi function to check whether a person has an obesity issue. According to the BMI scale, someone with a bmi between 30.0 and 54 is said to have obesity. We will pass a function as an argument, as follows:

const bmi = (weight, height) => weight / (height * height);
const hasObesity = (bmi) => bmi >= 30.0 && bmi <=54;
console.log(hasObesity(bmi(100, 2.2)));
主站蜘蛛池模板: 芒康县| 阿合奇县| 湘阴县| 云安县| 庄河市| 营口市| 武鸣县| 保山市| 宁安市| 疏勒县| 竹山县| 平谷区| 柯坪县| 六枝特区| 凯里市| 隆子县| 公主岭市| 赫章县| 乌审旗| 江永县| 金平| 牡丹江市| 汝南县| 岑溪市| 新竹市| 敦化市| 上杭县| 称多县| 天镇县| 海丰县| 右玉县| 威海市| 小金县| 海盐县| 利辛县| 海原县| 镶黄旗| 南平市| 敖汉旗| 富顺县| 双鸭山市|