nodejs
javascript 3
퓨처디벨로퍼
2021. 11. 28. 20:53
javascript 함수의 기본문법
f123();
function f123(){
console.log(1);
console.log(2);
console.log(3);
}
APP제작 - 함수를 이용해서 정리 정돈하기
function templateHTML(title, list,body){
return `
<!doctype html>
<html>
<head>
<title>WEB1 - ${title}</title>
<meta charset="utf-8">
</head>
<body>
<h1><a href="/">WEB</a></h1>
${list}
${body}
</body>
</html>
`;
}
function templateList(filelist){
var list = '<ul>'
var i = 0;
while(i<filelist.length){
list = list + `<li><a href="/?id=${filelist[i]}">${filelist[i]}</li>`
i = i+1;
}
list = list + '</ul>'
return list;
}
var list = templateList(filelist);
var template = templateHTML(title, list, ` <h2>${title}</h2><p>${description}</p>`);