即使在数组中包含value,Array.includes(value)也不会返回true

时间:2019-05-09 13:28:10

标签: javascript html

Array.includes(value)即使value在数组中也不会返回true。

let country = 'Ghana';
let weight = 75;
let height = 6 * 0.3048;

let healthyDietCountry = [
  'Chad',
  'Sierra Leone',
  'Mali',
  'Gambia',
  'Uganda',
  'Ghana',
  'Senegal',
  'Somalia',
  'Ivory Coast',
  'Isreal'
];

let bmi = healthyDietCountry.includes(country)
  ? (weight / Math.pow(height, 2)) * 0.82
  : (weight / Math.pow(height, 2))

console.log(bmi);

如果该国家/地区包含在HealthyDietCountry中,我应该得到的答案是18.388346962 ,但是代码却返回22.424813361。

0 个答案:

没有答案