JavaScript
ミニマム実践!HumanクラスをつくってBMIを計算してみる
出典: JavaScriptでのクラス定義方法とコンストラクタ定義まで!ミニマム実践してみる! — ミニマム実践!HumanクラスをつくってBMIを計算してみる
class human {
constructor(name,height,weight){
this.name = name;
this.height = height;
this.weight = weight;
}
getSquare(){
return parseFloat(this.height/ 100 ^ 2)
}
getBmi(){
return this.weight / this.getSquare()
}
}
▸ この snippet は実行結果未収録
▸ 実行結果は未収録です
Source収録記事
この snippet は記事の「ミニマム実践!HumanクラスをつくってBMIを計算してみる」セクションに登場する。コードの前後の文脈・ハマりどころの解説は記事本文で。
同じ記事から
4 件class human { constructor(コンストラクタでの引数){ コンストラクタ内での処理 }未収録
JavaScriptでのクラス定義方法
#6dffc51c6042
class human { constructor(){ console.log('Hello World') }
▶ 実行可
コンストラクタとは?
#92eab64d49da
class human { constructor(name,height,weight){ this.name = name; this.height = height;
▶ 実行可
ミニマム実践!HumanクラスをつくってBMIを計算してみる
#f37a77a8c6bb
class human { constructor(name,height,weight){ this.name = name; this.height = height;
▶ 実行可
ミニマム実践!HumanクラスをつくってBMIを計算してみる
#6268bb7340a3
