1. 문자열 7 , 8
2020. 6. 28. 16:20ㆍRetrospection/Sprint
7.
Given a name and a password, "areValidCredentials", returns true if the name is longer than 3 characters, AND, the password is at least 8 characters long. Otherwise it returns false.
function areValidCredentials(name, password) {
// your code here
}
function areValidCredentials(name, password) {
if(name.length >3 && password.length >= 8){
return true;
}return false;
}
이름과 비밀번호 길이가 각 3보다 크고 8 이상이라고 해서 그부분을 if 문 안에 넣어줬다.
8.
Given 3 words, "findMinLengthOfThreeWords" returns the length of the shortest word.
function findMinLengthOfThreeWords(word1, word2, word3) {
// your code here
}
function findMinLengthOfThreeWords(word1, word2, word3) {
let shortestWord = word1;
if(word1.length > word2.length){
shortestWord = word2;
if(word3.length < word2.length){
shortestWord = word3;
}
}else if(word1.length > word3.length){
shortestWord = word3;
}
return shortestWord.length;
}
6번을 하는데 개고생 했더니
8번은 엄청 쉬웠다. 그냥 .length 만 붙여서 리턴하는 것 밖에 없었음.
'Retrospection > Sprint' 카테고리의 다른 글
2. 타입 1 ~3 (0) | 2020.07.02 |
---|---|
2. 수학 - 1~3. (0) | 2020.07.02 |
1. 문자열 4 ~ 6 (0) | 2020.06.28 |
1. 문자열 1~3 (0) | 2020.06.28 |
0. 조건문 9 , 10 (0) | 2020.06.28 |