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 trialKelvin Akinola-Ajayi
701 PointsWhy is my alert box not appearing, my js and HTML file are identical to the video
<!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/mutiple-returns.js"></script>
</body>
</html>
function isFieldEmpty() { const field = document.querySelector('#info'); if (field.value === '') { return true; } else { return false; } }
const fieldTest = isFieldEmpty();
if (fieldTest === true) { alert('Please provide some information'); }
1 Answer
Steven Parker
231,269 PointsYou forgot to identify the video, but I think you meant Using Multiple return Statements from the JavaScript Functions course.
Your code seems to function correctly when I try it. Be aware that in its current state, it only runs when the page is first loaded. It does not run when you enter something into the field.