nodejs 관련 간단한 함수 작성 중입니다.
function templateList(){
var templateList;
fs.readdir('./data',function(err,fileList){
//./data 안의 파일의 갯수는 총 3개입니다.
templateteList = `<ul>`;
for(var i = 0 ; i < fileList.length ; i++){
templateList += `<li>${i}</li>`;
}
templateList += `</ul>`;
});
return templateList;
}
위의 코드에서 templateList 의 예상 결과값은 <ul><li>1</li><li>2</li><li>3</li></ul>
입니다.
하지만 결과값은 <ul></ul>
가 나옵니다.
이유 아시는분 답변 부탁드립니다 ㅠㅠ