졸꾸 코딩일기 21.6.22

David K·2021년 6월 23일
0

졸꾸 코딩일기 2021

목록 보기
7/31
post-thumbnail

건강관리

  • 산책 X
  • 스트레칭 V

코딩기록

계산기 과제

  • 베어미니멈(완료) - 어드벤스드(완료) - 나이트메어(마지막 한개 남음)

if (action === 'number') {
       if(firstNum === undefined){
         display.textContent = buttonContent
         firstNum = buttonContent
       }else{
        display.textContent = display.textContent + buttonContent
       }
         lastNum = display.textContent
    }
    
if (action === 'operator') {
      firstNum = undefined
      dotNum = undefined
      previousNum = display.textContent
      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
    }  
 
if (action === 'calculate') {
      preCalculate = 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)
      }
     }
    } 

피드백

  • 아쉽지만 뭔가 하드코딩 되어있는 부분들이 보인다.
  • 특히 마지막 테스트를 통과하려면 대대적인 변화가 필요할 것 같다.
profile
배워서 남 주자

0개의 댓글

관련 채용 정보