Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Callback Functions in JavaScript Introduction to Callback Functions Creating an Anonymous Callback Function

Powell Barrett
seal-mask
.a{fill-rule:evenodd;}techdegree
Powell Barrett
Full Stack JavaScript Techdegree Student 5,241 Points

Not sure what I have done wrong on Callback Function in JavaScript

Can someone take a look at my code and tell me what I have done wrong here, I keep getting a unexpected token on 1:9 where the parentheses is located

app.js
function () {
    console.log("Hello World!"); 
 }

functionRunner(log() => {
    console.log("Hello World!"); 
 });
index.html
<!DOCTYPE html>
<html lang="en">
    <head>
        <title></title>
        <link rel='stylesheet' href='styles.css'>
    </head>
    <body>
        <section>
            <p>Open your browser's console to see the results</p>
        </section>
        <script src='runner.js'></script>
        <script src='app.js'></script>
    </body>
</html>
runner.js
function functionRunner(callback) { 
  callback();
}

1 Answer

Steven Parker
Steven Parker
215,372 Points

It looks like you made "log" anonymous, but instead of moving it into the call of "functionRunner" you put something else there (which doesn't have valid syntax).

Just move the new anonymous function into the call. When done, everything should be in the call.

Note that you don't need to convert to arrow syntax for this challenge.