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 trialAlessandra Cruz
8,058 PointsCreating a fuction
it's asking for the code needed inside the function that would make a dialogue appear. I've tried a few ways but idk.
function sayHi(){
}
<!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>
1 Answer
Nikos Papapetrou
6,305 PointsYou have created right an empty function as the 1st task of the challenge require. Then you have to write the code you want (inside the function code block) to be executed when you invoke the function.
function sayHello() {
//my code here
console.log('Hello there!');
}
//Here we only define the function and it is not being executed. So you will not see any result.
After you have define the function to see the result of your code you have to invoke the function- Function Invocation. To invoke a function you write the name of the function you have created and parenthesis:
sayHello();
//sayHello() will be executed and will appear in the console.
Alessandra Cruz
8,058 PointsAlessandra Cruz
8,058 PointsThank You! This really cleared it up for me!