Skip to content
This repository has been archived by the owner on Sep 8, 2021. It is now read-only.

Latest commit

 

History

History
42 lines (36 loc) · 1.83 KB

ex01.md

File metadata and controls

42 lines (36 loc) · 1.83 KB

Exercise 01 - 누군지 모르겠지만 안녕!

제출할 폴더 이름 : ex01
제출할 파일 이름 : helloSomeone.js, package.json
사용 가능한 외부 모듈 : 없음
참고사항 : 없음

실행 시 매개변수를 가져와 인사를 출력하는 함수 helloSomeone을 작성하세요. 매개변수로는 문자열, 숫자, NaN, undefined, null이 들어올 수 있으며, 어떤 매개변수냐에 따라 다음과 같은 동작을 하는 함수를 구현해야 합니다.

  • 매개변수로 문자열이 들어온 경우, "Hello 문자열!" 을 출력해야합니다. 만약 문자열이 빈 문자열이라면 "Who are you?" 를 출력합니다.
  • 매개변수로 null 이 들어온 경우, "I am null and void" 를 출력해야합니다.
  • 매개변수로 숫자가 들어온 경우, "My age is 숫자" 를 출력해야합니다. 단, 숫자가 음수나 0 의 경우 "I am Benjamin Button!" 을 출력합니다.
  • 매개변수로 NaN가 들어온 경우, "Age is just a number" 를 출력해야합니다.
  • 매개변수로 undefined가 들어온 경우 "Nobody can define me!" 를 출력해야합니다.

💡 테스트시 다음과 같은 코드가 적혀 있는 파일을 폴더에 넣어 실행합니다.

// test.js
import helloSomeone from './helloSomeone.js'
helloSomeone("42");
helloSomeone("");
helloSomeone(null);
helloSomeone(42);
helloSomeone(-1);
helloSomeone(NaN);
helloSomeone(undefined);
> node test.js | cat -e
(node:87794) ExperimentalWarning: The ESM module loader is experimental.
Hello 42!$
Who are you?$
I am null and void$
My age is 42$
I am Benjamin Button!$
Age is just a number$
Nobody can define me!$