
이름과 성을 입력받아 띄어쓰기 하나를 사이에 둔 단일 문자열을 리턴해야 한다.
인자 1 : firstName
인자 2 : lastName
et output = getFullName('Joe', 'Smith');
console.log(output); // --> 'Joe Smith'
정답
function getFullName(firstName,lastName) { return firstName + ' ' + lastName ; }
이름과 나이를 입력받아 나이별로 다른 메시지를 리턴해야 한다.
인자 1 : name
인자 2 : age
let output = checkAge('Adrian', 22);
console.log(output); // --> "Welcome, Adrian!"
let output2 = checkAge('John', 17);
console.log(output2); // --> "Go home, John!"
정답
function checkAge(name,age){ if ( age > 20 ) { return "Welcome, " + name + "!"; } else { return "Go home, " + name + "!"; } }
단어를 입력받아 단어의 길이를 리턴해야 한다.
인자 1 : word
let output = getLengthOfWord('DevOps');
console.log(output); // --> 6
정답
function getLengthOfWord(word) { if (word.length > 0) { return word.length; } else { return 0; } }