<script>
//変数を作る
let select;
let yenMoney;
let usaMoney;
let doru = 106;
//関数式で記載
const getYenToDoru = (number) => {
return number / doru;
}
const getDoruToYen = (number) => {
return number * doru;
}
//繰り返し行う。
while(true){
select = prompt('両替しますか?(【1】円→ドル 【2】ドル→円)');
if(select === '1'){
yenMoney = prompt('金額を入力してください');
console.log(getYenToDoru(yenMoney) + 'ドルになります');
break;
}else if(select === '2'){
usaMoney = prompt('金額を入力してください');
console.log(getDoruToYen(usaMoney) + '円になります。');
}
//数値が入力されていなかったり、キャンセルした場合は終了
else break;
}
</script>
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme