tried couple of things and was not successful. What am I missing here? I just want to do a simple alert or log, and I am not able to. Here is what I have:
function toggleEmail() {
var isChecked = document.getElementById("subscribe");
if (isChecked.checked) {
console.log('Yep, my function is being called');
}
}
toggleEmail();
<title>JavaScript Challenges</title>
</head>
<body>
<form action="">
<fieldset>
<legend>Email subscriptions</legend>
<p id="subscribe">
<label>
<input type="checkbox" name="subscribe" id="subscribe" onclick="toggleEmail()" />
Yes! I would like to receive all of your free candy!
</label>
</p>
<p id="emailpara">
<label>
<head>" instead.)