As I can see in your code, there is nowhere to add created elements to HTML.
And when it comes to open prompt, you should get value from the input.
This is how to get input value and reflects it to the HTML
let todos = []
function createTodo() {
let newTodo = {
text: '',
checked: 0
}
newTodo['text'] = prompt('Item description')
if( newTodo.text != null ) {
todos.push(newTodo)
reflectToHtml(newTodo)
}
}
function reflectToHtml(i) {
let listItem = document.createElement('li')
let itemText = document.createTextNode(i['text'])
listItem.appendChild(itemText)
document.getElementById('todo-list').appendChild(listItem)
document.getElementById('item-count').innerText = todos.length
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…