이번 문제도 마찬가지로 내가 이해한대로 해석해서 풀었다.
js파일
// 1 <= strings길이 <= 50
// strings의 원소는 소문자로 이루어져있음
// 1 <= strings의 원소 길이 <= 100
// 모든 strings의 원소 길이는 n보다 큼
let arr = ['abcs', 'adfw', 'dfds']
let [str1, str2, str3] = arr
let nscanf = prompt('n을 입력하세요.' + "")
let one = str1.charCodeAt([nscanf])
let two = str2.charCodeAt([nscanf])
let three = str3.charCodeAt([nscanf])
if (one <= two) {
if (one <= three) {
if (two <= three) {
alert('[' + str1 + ']' + '[' + str2 + ']' + '[' + str3 + ']')
}
else {
alert('[' + str1 + ']' + '[' + str3 + ']' + '[' + str2 + ']')
}
}
else {
alert('[' + str3 + ']' + '[' + str1 + ']' + '[' + str2 + ']')
}
}
if (one > two) {
if (one >= three) {
if (two <= three) {
alert('[' + str2 + ']' + '[' + str3 + ']' + '[' + str1 + ']')
}
else {
alert('[' + str3 + ']' + '[' + str2 + ']' + '[' + str1 + ']')
}
}
else {
alert('[' + str2 + ']' + '[' + str1 + ']' + '[' + str3 + ']')
}
}
html파일
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src ="hbook_2.js"></script>
</body>
</html>
'내일배움캠프 > JavaScript handbook' 카테고리의 다른 글
1. 문제 (0) | 2023.05.01 |
---|---|
핸드북 사이트 (0) | 2023.04.24 |