응용 숙제에서 forEach를 함수로 만들어보라고 하셔서 다음과 같이 짜보았는데 data.addTemplet is not a function. 이라는 에러문구와 함께 실행이 되질 않습니다. ㅠ ㅠ
이유가 무엇일까요?
<script>
function addTemplet( ){
forEach(function(a){
var 템플릿 = `<div class='col-sm-4'>< img src='https://via.placeholder.com/600' class='w-100'><h5>${a.title}</h5><p>${a.price}</p></div>`
$('.row').append(템플릿);
});
}
var count = 0;
$('.btn').on('click',()=>{
count = count + 1;
if(count == 1){
$.get('https://codingapple1.github.io/js/more1.json')
.done(function(data){
data.addTemplet();
})
} else if (count == 2){
$.get('https://codingapple1.github.io/js/more2.json')
.done(function(data){
data.addTemplet();
$('.btn').css('display','none');
})
}
});
</script>