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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Brian CI](https://secure.gravatar.com/avatar/447adb6539ec09a8618b979eeee6d7ab?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Brian CI
28,971 PointsMy function is only being called once
var myFunction = function () {
console.log('myFunction was called');
};
var callTwice = function (targetFunction) {
targetFunction();
targetFunction();
};
callTwice(myFunction);
It should be called twice but I only get the output "myFunction was called" once.
Also why does Jim use }; sometimes but other times just }? See screen shot: http://s28.postimg.org/xnvdoti59/image.png
4 Answers
![Dino Paškvan](https://secure.gravatar.com/avatar/ed70065c529ecafe5e2a0337493b9267?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Dino Paškvan
Courses Plus Student 44,108 PointsCheck your output thoroughly. Firefox won't display the output text twice, instead it'll show a counter on the right side of the console to display how many times the same message has been logged.
![Ryan Scharfer](https://secure.gravatar.com/avatar/30bf9be387ae533550196ef3995508a4?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ryan Scharfer
Courses Plus Student 12,537 PointsHi Brian,
I am copying and pasting your code in my console, and the function gets called twice... I think Jim just forgot the semi-colon there.
![Brian CI](https://secure.gravatar.com/avatar/447adb6539ec09a8618b979eeee6d7ab?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Brian CI
28,971 PointsI just get it once... can this be some kind of peculiarity of FireFox vs. Chrome?
![Ryan Scharfer](https://secure.gravatar.com/avatar/30bf9be387ae533550196ef3995508a4?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ryan Scharfer
Courses Plus Student 12,537 Pointshm. I am using Chrome. Are you sure you just don't see it? Can you stretch the console to make sure you're not missing anything?
Brian CI
28,971 PointsBrian CI
28,971 PointsI have seen that before and this was part of it.
I also noticed that in the tutorial he leaves in a line "undeclaredVariable;" which I didn't put above but I think I had in my code. I don't know if this works in chrome but in firefox it stops executing at that line. So I think I had two issues. I'm coming back and looking at this after a couple weeks.
it's line 53 in the video and you can see it around 9.40. You cannot continue with the tutorial in firefox without either removing or commenting out that line.
What I thought was being displayed only once was actually the original console.log('myFunction was called'); on line 52 and it was only appearing once.
I don't know if this makes sense but in short, in firefox, the "Hello from the anon function!" or 'myFunction was called' will only be displayed twice if there are no lines "undeclaredVariable;"
Brian CI
28,971 PointsBrian CI
28,971 PointsIt also seems like there's a ';' missing at the end of line 72 at the end of the video. It doesn't work for me without adding it.