
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
let 으로 변수 선언 안하고 바로 J쿼리 써도 되나요? 결과는 잘 나옵니다.
숙제 답안 코드 (전체 화면 캡쳐)는 let으로 temp 데이터 를 temp 변수에 넣고 쿼리로 변수를 갖다 붙인 것 같은데,
작성한 코드와 같이 J쿼리에서 바로 데이타에서 'temp' 선정한 다음 텍스트로 만들어줘도 괜찮나요?
제가 이해한 내용이 맞을까요?
<script>
$(document).ready(function() {
fetch("http://spartacodingclub.shop/sparta_api/weather/seoul").then(res => res.json()).then(data => {
// console.log(data)
let temp = data['temp']
$('#temp').text(temp)
})
})
</script>
<script>
$(document).ready(function () {
fetch("http://spartacodingclub.shop/sparta_api/weather/seoul").then(res => res.json()).then(data => {
$('#temp').text(data['temp'])
})
})
</script>
