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 trialvellon rasmos manzvanda
8,012 Pointsrunning javascript from external file
hie guys pretty stuck here need some help. i am doing javascript basics and i am doing my practice on notepad++ and brackets. i am only able to use the alert("whats your name") and prompt(), but thats far as it goes. if i write the if else statement or function nothing appears on my preview or browser.
2 Answers
rhysdamagnez
14,394 PointsHi Vellon,
I can't be 100% from your explanation but you need to call functions, they don't run automatically.
Please can you share the code you're having issues with.
vellon rasmos manzvanda
8,012 Pointsthanks rhysdamagnez iwas able to see where the problem was
vellon rasmos manzvanda
8,012 Pointsvellon rasmos manzvanda
8,012 Pointshow do i call a function or even a variable. here is my code if (day < 7) { greeting = "happy week"; }
rhysdamagnez
14,394 Pointsrhysdamagnez
14,394 PointsThe code you've supplied is a conditional (if statement) and inside that you have a statement which sets the variable greeting to a string with the value "happy week".
Let's say you're using that code to set an alert. You might do something like this.
Only when I use the alert() method does anything happen.
Hopefully that helps :)