Creating a function in JS

I have been asked to create a function called ‘reusableFunction’ that prints “Hi World” in the console,and to then call the function. This is my code but its returning an error saying that reusableFunction is not defined. help.

function reusableFunction() {
console.log("Hi World");
}
reusableFunction();

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0.

Challenge: Write Reusable JavaScript with Functions

Link to the challenge:

Hi,

the quotes “” you use are not the same as “”!

Try to copy “Hello World” from the given text and paste it!

I hope it helps!

2 Likes

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like

Your code passes the test when I run them.
Here are some things to check:

  • Reset the challenge and put your solution in again.
  • Make sure that you are using a supported browser (Chrome, Firefox, Safari, Edge).
  • Check your browser for updates. (Firefox in particular recently had an oops with a minor version change and needs to be up-to-date.)
  • Turn off any extensions such as ad blockers or script blockers for freeCodeCamp (these can prevent JavaScript from executing normally, and our tests are JavaScript.)