
JS codeで自分なりにコード書いてみた
問いは
15 歳以下は 800 円、女性の場合には 1000 円、 そうではない場合には 1800 円の映画のチケットがあります。
年齢と性別を変数に代入すると、チケットの値段を教えてくれるプログラムを書いてみましょう。
15 歳以下かつ女性の場合には、 800 円 となるものとします。
例として、16 歳の女性のチケットの値段を出して下さい。
自分の書いたコード
(function(){
'use strict';
var age =16;
var female= true;
var result=null;
if(age<=15 && female) {
result='800';
} else if (age<=15) {
result='800';
} else if (female){
result='1000';
} else result='1800';
document.write(result);
}) ();
計算の結果、(age<=15 && female)この部分は要らなかったかなって感じです。
日々進歩しております。にしても、プログラミング楽しい!!
Leave JS codeで自分なりにコード書いてみた to:
Read more #programing posts
Best Posts From masamasag
We have not curated any of masamasag's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.