<h2>When is Sehwa's birthday?</h2>
<label>month</label>
<input class="date" id="month" value="" type="number" min="1" max="12">
<label>day</label>
<input class="date" id="day" value="" type="number">
<button>I'm sure!</button>
const month = document.querySelector("#month");
const day = document.querySelector("#day");
if ((month.value ==="8") && (day.value === "11")) {
congrats();
8과 11로 제대로 입력을 해도 if문의 코드가 자꾸 실행되지 않았다. 그래서 month.value와 day.value의 type를 콘솔에 찍어보니 얘네는 string 이었다.
👀 input type="number", 숫자로 받았는데도 ?
👉 찾아보니 html은 data type에 대한 개념이 없다고 한다. 그래서 모든 값들이 다 string임.
input tag는 HTML Input Element 인터페이스가 정의했고, 그 값의 속성은 숫자의 형태를 가진 DOMString이다.
month.valueAsNumber, day.valueAsNumber 로 작성하면 숫자로 받을 수 있다. 또는 ParseInt를 쓰기.