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]

相比之下我们挨个老实写简直就是toyCode


  • 1

Reply