
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
$(document).ready(function () {
let url = "http://spartacodingclub.shop/sparta_api/weather/seoul";
fetch(url).then(res => res.json()).then(data => {
let temp = data['temp'];
let a = ('추워요');
let b = ('더워요');
let temp_html =``;
if (temp > 20){
$('#temperature').text(b);
} else(temp < 20){
$('#temperature').text(a);
}
$('#temperature').text(temp);
})
})
마지막 숙제쪽에서 20도가 넘으면 더워요 낮으면 추워요 if문을 만들래서 이렇게 만들어봣는데 당연히 실행은 안되서 질문드리는거고,
let temp는 저 url의 data안에 있는 temp만을 끄집어 내는 함수이고 그 함수값을 크게 묶으려고 temp_html을 사용하였고,
if (temp>20){
$('#temperature').text(b);
}
이런식으로 안에 내용을 $('#temperature').text(b);로 넣어야
20도가 넘을시 $('temperature')쪽에 text를 (b) 즉 더워요로 치환한다 이런 표현아닌가요? 뭐가 잘못된걸까요
