Messed up with a basics.
As I press the enter key or click the button, list array's element is changed, not appended the new element I wrote.
Also, I would like to reset for <input type='text' maxlength='8' id='aName' placeholder='Write a name.' onKeyDown='enterkey();' />, but have no clue to do.
How can I amend the code below?
function enterkey() {
if (window.event.keyCode == 13) {
pushingName();
}
}
function pushingName(){
var list=[];
var oneName = document.getElementById('aName').value;
var stringName = oneName.toString();
var nameList = list.push(stringName);
console.log(list);
}
<input type='text' maxlength='8' id='aName' placeholder='Write a name.' onKeyDown='enterkey();' />
<button onclick='pushingName();'>ADD</button>