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

JavaScript JavaScript Basics (Retired) Creating Reusable Code with Functions Review Creating Reusable Code with Functions

creating reusable codes with functions

Given this function, write the code to call it:

function warning() { alert('Warning, warning, warning!'); }


i think it might be warning();

4 Answers

Christian Linnerud
Christian Linnerud
7,312 Points

Type this and you will pass this question.

warning()

The semi colon ; is already typed into the questions.

Thanks, very helpful

Hi,

To call the function simply write the name of the function followed by brackets and semi colon...

//name of function alertRandom
function alertRandom() {
//function
  var randomNumber = Math.floor( Math.random() * 6 ) + 1; 
  alert(randomNumber);
}

//call function alertRandom
alertRandom(); 

Hope this helps!

Craig

Jonathan Dalby
Jonathan Dalby
8,528 Points

How annoying, this was driving me nuts !!!! All about attention to detail I guess, dammit!