졸꾸 코딩일기 21.6.23

건강관리

  • 산책 V
  • 스트레칭 V

코딩기록

계산기 과제

  • 베어미니멈(완료) - 어드벤스드(완료) - 나이트메어(완료)
 if (target.matches('button')) {
    if (action === 'number') {
       if(firstNum === undefined){
         display.textContent = buttonContent
         firstNum = buttonContent
       }else{
        display.textContent = display.textContent + buttonContent
       }
         lastNum = display.textContent
         copyCount = 0
    }
 if(action === 'operator'){
      firstNum = undefined
      dotNum = undefined
 if(copyCount === 0){
   if(count === 0){
          previousNum = display.textContent
          count = count + 1
          operatorForAdvanced = buttonContent
  }else if(calculateButton === undefined){
          display.textContent = calculate(previousNum, operatorForAdvanced, lastNum)
          previousNum = display.textContent
          operatorForAdvanced = buttonContent
        }
        copyCount = 1
      }   
if(lastNum === previousNum){
        operatorForAdvanced = buttonContent
      }
    }      
 if (action === 'decimal') {
       if(dotNum === undefined){
        if(firstNum === undefined){
          display.textContent = '0' + buttonContent
        }else{
          display.textContent = display.textContent + buttonContent
        }
        firstNum = buttonContent  
        dotNum = buttonContent
      }
    }
    if (action === 'clear') {
      display.textContent = '0'
      firstNum = undefined
      operatorForAdvanced = undefined
      previousNum = undefined
      lastNum = undefined
      dotNum = undefined
      count = 0
      copyCount = 0
      calculateButton = undefined
    }
if (action === 'calculate') {
    calculateButton = buttonContent
     if(operatorForAdvanced !== undefined){
      dotNum = undefined
 if(previousNum !== undefined){
    display.textContent = calculate(previousNum, operatorForAdvanced, lastNum)
    previousNum = undefined
  }else{
    display.textContent = calculate(display.textContent, operatorForAdvanced, lastNum)
      }
     }
    }
  }

피드백

  • 나이트메어를 정복했지만 하드코딩을 벗어날 방법을 딱히 찾아내지 못했다.
  • 동기의 과제와 과제의 레퍼런스를 보고 다시 피드백 할 예정이다.

좋은 웹페이지 즐겨찾기