Why is my code wrong


I’m doing “Intro to built-in PHP functions” chapter 5, and I’m getting an error.
This is my code:

function calculateDistance($first, $second)


    $result = $first - $second; 

    echo abs($result);


  calculateDistance(4, -1);

and this is the instruction:

You’re going to write a function which uses the abs() built-in function within its definition.

Write a function called calculateDistance() that calculates the distance between two numbers. The function should return the same result for two arguments no matter what order they’re passed into the function.

Here are some examples of how the function should work:

  • calculateDistance(-1, 4) should return 5
  • calculateDistance(4, -1) should return 5
  • calculateDistance(3, 7) should return 4
  • calculateDistance(7, 3) should return 4

Once you’ve finished writing your function, you should run it to make sure it’s working how it should.

Check out the hint if you want some help on the strategy or a reminder about how to define your own functions.

The results are as expected, but I’m still getting the error, what did I do wrong?

The solution provided is:

function calculateDistance($first, $second)


  return abs($first - $second);


Thank you!

Kind regards,

the crucial word in this sentence is return, your code echo's the result

return and echo do two different things

Oh I see, thanks
So I didn’t follow the instructions