[JS] ๊ธฐ๋ณธ์ฐ์ฐ์ ์ฐ์ต๋ฌธ์ 1, 2
2021. 10. 25. 23:09ใHTML + CSS + JS/JS ์๋ฐ์คํฌ๋ฆฝํธ
728x90
* ์ฐ์ต๋ฌธ์ 1
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title> ์ข
ํฉ์ค์ต1-1 </title>
<script>
var price1 = 3000;
var price2 = 6000;
var price3 = 3000;
var total = price1 + price2 + price3;
var result = (total > 10000) ? (total-10000) + "์ ์ด๊ณผ!" : "๋ ๊ด๋ฆฌ๋ฅผ ์ ํ์ด์!";
document.write(result);
</script>
</head>
<body>
</body>
</html>
* ์ฐ์ต๋ฌธ์ 2
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title> ์ข
ํฉ์ค์ต1-2 </title>
<script>
var avgSales = (1200 + 1300 + 1000)/ 3; //ํ๊ท ํ๋งค๋
var fourth = prompt("4๋ถ๊ธฐ ํ๋งค๋์?", "0");
var msg_1 = "ํ๋งค๋์ด ํ๊ท ์ด์์
๋๋ค.",
msg_2 = "ํ๋งค๋์ด ํ๊ท ๋ฏธ๋ฌ์
๋๋ค.";
var result = (fourth > avgSales) ? "ํ๋งค๋์ด ํ๊ท ์ด์์
๋๋ค." : "ํ๋งค๋์ด ํ๊ท ๋ฏธ๋ฌ์
๋๋ค.";
document.write(result);
</script>
</head>
<body>
</body>
</html>
728x90
'HTML + CSS + JS > JS ์๋ฐ์คํฌ๋ฆฝํธ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[JS] ์ ํ๋ฌธ(switch)์ ๋ฐ๋ณต๋ฌธ(while, do-while, for) ์ฐ์ต๋ฌธ์ (0) | 2021.10.26 |
---|---|
[JS] ์กฐ๊ฑด๋ฌธ (if, if-else, ์ค์ฒฉ if )์์ (0) | 2021.10.26 |
[JS] ์ฐ์ฐ์ (0) | 2021.10.25 |
[JS] ๋ณ์, ๋ฐ์ดํฐ ์ข ๋ฅ(๋ฌธ์ํString, ์ซ์ํ Number, ๋ ผ๋ฆฌํ Boolean, null, undefined ๋ฐ์ดํฐ) (0) | 2021.10.25 |
[JS] ์๋ฐ์คํฌ๋ฆฝํธ ๊ธฐ์ด ๋ฌธ๋ฒ (0) | 2021.10.25 |