混攻チャレンジ:混攻団第7期Javascript]独自学習のJavaScript第2週
第2週
基本タスク:p.139問題3題を確認し、完全なコードを生成し、visualstudioコードで結果認証を実行する
コード#コード#
<script>
if (x > 10) {
if (x < 20) {
console.log('조건에 맞습니다.')
}
}
</script>
<script>
if (x > 10 && x < 20) {
console.log('조건에 맞습니다.')
}
</script>
<!DOCTYPE html>
<head>
<title></title>
<script>
const x = prompt('x 값을 입력해주세요.', '')
if (x > 10 && x < 20) {
console.log('조건에 맞습니다.')
}
else {
console.log('조건에 맞지 않습니다.')
}
</script>
</head>
<body>
</body>
</html>
実行結果
タスクの選択:p.152の<干支の入力と出力>の例を実行して、本人の干支の出力の画面をキャプチャします。
コード#コード#
<script>
const rawInput = prompt('태어난 해를 입력해주세요.', '')
const year = Number(rawInput)
const e = year % 12
let result
if (e === 0) {result = '원숭이'}
else if (e === 1) {result = '닭'}
else if (e === 2) {result = '개'}
else if (e === 3) {result = '돼지'}
else if (e === 4) {result = '쥐'}
else if (e === 5) {result = '소'}
else if (e === 6) {result = '호랑이'}
else if (e === 7) {result = '토끼'}
else if (e === 8) {result = '용'}
else if (e === 9) {result = '뱀'}
else if (e === 10) {result = '말'}
else if (e === 11) {result = '양'}
alert(`${year}년에 태어났다면 ${result} 띠입니다.`)
</script>
<script>
const rawInput = prompt('태어난 해를 입력해주세요.', '');
const year = Number(rawInput);
let result
switch (year % 12) {
case 0:
result = '원숭이';
break;
case 1:
result = '닭';
break;
case 2:
result = '개';
break;
case 3:
result = '돼지';
break;
case 4:
result = '쥐';
break;
case 5:
result = '소';
break;
case 6:
result = '호랑이';
break;
case 7:
result = '토끼';
break;
case 8:
result = '용';
break;
case 9:
result = '뱀';
break;
case 10:
result = '말';
break;
case 11:
result = '양';
break;
}
alert(`${year}년에 태어났다면 ${result} 띠입니다.`)
</script>
実行結果
Reference
この問題について(混攻チャレンジ:混攻団第7期Javascript]独自学習のJavaScript第2週), 我々は、より多くの情報をここで見つけました https://velog.io/@kjhwan1994/혼공챌린지-혼공단-7기-Javascript-혼자-공부하는-자바스크립트-2주차テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol