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 trial
Veronika Benkeser
2,930 Pointsmyscript.js
Hello, I am trying to do a function within a function, but it is not executing.
var world = "World!";
function sayHello () { var hello = "Hello ";
function inner () {
var extra = " There is more!";
console.log(world + extra);
}
inner();
}
Thank you for your help.
2 Answers
Guled A.
10,605 PointsVeronika, you had forgotten to call your sayHello function. You called the inner function within the sayHello function, but since it's inside another function, sayHello must also be called.
var world = "World!";
function sayHello () {
var hello = "Hello ";
function inner () {
var extra = " There is more!";
console.log(world + extra);
}
inner();
}
sayHello(); // <-----
Veronika Benkeser
2,930 Pointsthank you!
Guled A.
10,605 PointsNo problem. :)
Gregg Mojica
11,506 PointsGregg Mojica
11,506 PointsCould you please update your question? As it stands now, there is nothing there.