So I'm pretty new to js. I've tried to make a button that logs hey
in the console, but it already logs it before clicking the button. And when clicking the button it won't do anything. This is my code.
let btn1 = document.getElementById("btn1");
btn1.onclick = console.log('hey');
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input value="test" type="button" id="btn1" data="onclick">
</body>
</html>