Better-React / ReactBestPractice

0 stars 0 forks source link

20220115_실습 #1

Open hi-jade88 opened 2 years ago

hi-jade88 commented 2 years ago
function printFactory(name) {
  return function(idx) {
    const printDic = {
      [-1]: '잘못된 입력입니다.',
      0: `반가워 나는 ${name}`,
      1: `잘가 나는 ${name}`
    }

    return console.log(printDic[idx])
  }
}
dongkyun-dev commented 2 years ago
const printFactory = (name) => (num) => {
     num === 0 
        ? console.log(`반가워 나는 ${name}`)
        : console.log(`잘가 나는 ${name}`)   
}
Park-Joyeong commented 2 years ago
const printFactory = name => (
    num => {
        if (num === 0) {
            console.log('반가워 나는 ' + name);
        } else if (num === 1) {
            console.log('잘가 나는 ' + name);
        }
    }
)