‫Okay.
‫So we're going to do a little challenge here with the job listings.
‫So this is exactly where we left off.
‫So for the starter code for this particular lesson you can find in that folder.
‫So there's a couple of things we want to do.
‫We want to refactor the format salary function to an arrow function.
‫And just to remind you let's come down here.
‫So this is the format salary.
‫Very simple.
‫Good candidate for an arrow function.
‫Since it's just a single return, a single line return, then it's no longer going to be a named function.
‫It will be a variable.
‫So we need to change the name in the two places that it's called, which is once in inside the calculate
‫average salary function.
‫And then once down here of course, where we're actually formatting the salary in the web page.
‫All right.
‫Now one of the calls is in another function.
‫That's the calculate salary.
‫So it's a variable.
‫It will no longer be available in the scope of the function.
‫Right.
‫Because before let's go back up here.
‫So right now it's a named function.
‫So I can use it.
‫But if we change that to an arrow function it will then be a variable.
‫And the format salary variable is in the outer scope.
‫So you need to handle that think callback.
‫All right.
‫So pause the video try it out and let's get started.
‫So I'm going to go up to format salary.
‫And first thing I'm going to do is get rid of the name.
‫And then we're going to put that into a variable called format salary.
‫And then we're going to add our arrow.
‫Actually let's change function to fn.
‫Then we have our arrow.
‫We want to get rid of the ending curly brace.
‫We want to get rid of the explicit return and the opening curly brace.
‫So very simple.
‫All right.
‫Now that's not going to work.
‫It's going to break because it's looking for a named function of format salary.
‫So we got rid of that.
‫Now we have this variable which holds the function.
‫So let's come down to the HTML.
‫And all we have to do here is simply add the dollar sign onto on to that.
‫That will take care of of that one.
‫However, if we do that here and calculate average where we have return format salary, if I add that
‫and reload I get undefined variable format salary.
‫So it's different depending on if it's a function or if it's an anonymous function in a variable.
‫Right.
‫Because now this format salary is outside in this scope in the global scope.
‫So what we can do is pass in format salary as a callback.
‫And then we can access it from within here.
‫So let's save that reload.
‫Okay, so one more thing I forgot.
‫It says too few arguments to the function calculate average salary.
‫So I added the parameter here to be taken in, but I didn't actually pass it in.
‫So let's go to where we have calculate average salary and let's pass in.
‫Format salary like that.
‫So now it works.
‫So you can see it's the salary is formatted here.
‫And where we're using calculate average and it's formatted here where we're using it directly in the
‫HTML.