```
var date;
document.getElementById("myButton1").onclick = function(){
    date = document.getElementById("myText1").value;   

}
console.log(date);

```

Why does this code not work? I'm new to js and i cant find the answer anywhere.