Discuss / JavaScript / O(1) level algorithm (doge)

### O(1) level algorithm (doge)

Topic source

#### 生而为弟

#1 Created at ... [Delete] [Delete and Lock User]

var bmi = weight / height / height;

var trans_bmis = [bmi - 18.5 < 0, bmi - 25 < 0, bmi - 28 < 0, bmi - 32 < 0];

var std = ["过轻", "正常", "过重", "肥胖", "严重肥胖"];

var idx = trans_bmis.indexOf(true);

if (idx === -1) {

idx = 4;

}

console.log(std[idx]);

#### 生而为弟

#2 Created at ... [Delete] [Delete and Lock User]

replace time with space

#### 张中硕

#3 Created at ... [Delete] [Delete and Lock User]

#### 雏鹰

#4 Created at ... [Delete] [Delete and Lock User]

#### 江K60

#5 Created at ... [Delete] [Delete and Lock User]

#### ～曉瘋～

#6 Created at ... [Delete] [Delete and Lock User]

var bmi = weight / height / height;

var trans_bmis = [bmi - 18.5 < 0, bmi - 25 < 0, bmi - 28 < 0, bmi - 32 < 0,bmi - 32 >= 0];

var std = ["过轻", "正常", "过重", "肥胖", "严重肥胖"];

var idx = trans_bmis.indexOf(true);

console.log(std[idx]);

#### 熊熊爱吃冰鲜鱼

#7 Created at ... [Delete] [Delete and Lock User]

• 1