const keyword = "***住宿一般多少钱一晚"
const usefulInfo = [
"荃湾西如⼼酒店5星级",
"大学宿舍费用",
"周边租房价格",
"寄宿位费用",
"***行程路线规划",
"普通酒店价格"
]
const relevantInfo = [
"荃湾西如⼼酒店5星级",
"大学宿舍费用",
"周边租房价格",
"寄宿位费用",
"***行程路线规划",
"普通酒店价格"
]
function generateArticle() {
const articleElement = document.createElement("article")
const headingElement = document.createElement("h1")
headingElement.textContent = keyword
articleElement.appendChild(headingElement)
const introParagraph = document.createElement("p")
introParagraph.textContent = "***拥有多达520家酒店和住宿供人选择。从价格低廉的到价格昂贵的,评级和评分也各不相同。选择入住日期可以查看最新的价格和优惠信息。"
articleElement.appendChild(introParagraph)
const usefulInfoSection = createSection("有用的相关内容", usefulInfo)
const relevantInfoSection = createSection("详细介绍", relevantInfo)
articleElement.appendChild(usefulInfoSection)
articleElement.appendChild(relevantInfoSection)
document.body.appendChild(articleElement)
}
function createSection(title, infoList) {
const sectionElement = document.createElement("section")
const headingElement = document.createElement("h3")
headingElement.textContent = title
sectionElement.appendChild(headingElement)
const listElement = document.createElement("ul")
for (let i = 0
i < infoList.length
i++) {
const listItemElement = document.createElement("li")
listItemElement.innerHTML = infoList[i]
listElement.appendChild(listItemElement)
}
sectionElement.appendChild(listElement)
return sectionElement
}
generateArticle()