연습

AeRi Lee·2020년 1월 12일
0
 function allIsWell(who){
  if(who==="son") {
     return "nope!";
    } else if(who==="dad") {
     return "well?";
    } else if (who==="grand father") {
     return "It's been a while!";
    } else{
     return "who are you?";
    }
 }
 
 console.log(allIsWell("son"));
 console.log(allIsWell("dad"));
 console.log(allIsWell("grand father"));
 console.log(allIsWell("me"));
 
 

위에 코드는 비교연산자를 배우기 위해 짠 것.
여기에 처음에 son, dad 에 따옴표를 붙여도 동작하지 않길래
없애고 진행했었다.

그런데

코드에 예약된 키워드 (function, let, if, true, false 등등 따옴표가 필요 없는)를 제외한 모든 영어단어는 변수로 인식하기 때문에 변수가 아닌 string 데이터값을 표현하고 싶다면 꼭 따옴표를 써줘야 한다.......!!


profile
👩🏻‍💻 Junior Web Frontend Developer

0개의 댓글