Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialHina K.
4,806 PointsWhy is my alert box not popping up?
function isFieldEmpty() {
const field = document.querySelector('#info');
if (field.value ==== '') {
return true;
} else {
return false;
}
}
const fieldTest = isFieldEmpty();
if (fieldTest === true) {
alert("Please provide your information.");
}
Here is my HTML code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Functions</title>
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<main>
<input type="text" id="info">
</main>
<script src="js/multiple.returns.js"></script>
</body>
</html>
2 Answers
Hina K.
4,806 PointsFigured it out!
File name was incorrect. I fixed it to read
<script src="js/multiple-returns.js"></script>
boi
14,242 PointsYou have four equal signs on line 3.
function isFieldEmpty() {
const field = document.querySelector('#info');
if (field.value ==== '') { 👈
return true;
} else {
return false;
}
}
No error for that?
Mark Sebeck
Treehouse Moderator 38,105 PointsMark Sebeck
Treehouse Moderator 38,105 PointsGreat Job! I changed your comment to an answer and made it the best answer. Keep at it!