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 trialAndrew Alvarez
11,964 PointsHi
Inside the sayHi() function add the code to make an alert appear with the word "Hi" in it. The alert command should go inside the function's code block.
function sayHi() {
alert ("Hi");
}
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
5 Answers
Abe Layee
8,378 PointsYou have to call the function in order for it to work
function sayHi() {
alert('hi');
}
sayHi();//this is calling the function.
Iain Simmons
Treehouse Moderator 32,305 PointsHi Abe Layee, not sure if you were able to change this to an answer, so I've done that for you (as a mod).
Abe Layee
8,378 Pointsok. I am still getting use to this forum . If you don't mind me asking, how do I submit it an answer?
Abe Layee
8,378 Pointslol never mind, The answer is at the bottom of the page. I got it.
Abe Layee
8,378 PointsOk, thank you.
Omoniyi Yakub
Courses Plus Student 3,342 PointsCreate a variable for the 'Hi'. It will run.
function sayHi() { var message = "Hi"; alert(message); } sayHi();
Jason Headley
2,884 Pointsfunction sayHi() { alert("Hi"); }
//worked for me
geoffrey
28,736 Pointsgeoffrey
28,736 PointsHey Abe Layee , good answer, but try to move it as answer. This way that can be marked as best answer ;-).