let lesson = [
{
title: "语文",
author: "张三",
},
{
title: "数学",
author: "李四",
},
{
title: "英语",
author: "王五",
},
];
function template() {
return `
<ul>${lesson
.map((item) => links`<li>课程:${item.title} 老师:${item.author}</li>`)
.join("")}</ul>`;
}
function links(strings, ...vars) {
return strings.map((item, index) => item + (vars[index] || ""));
}
网友评论