Now essentially all we really want to do here is take a string that is provided as an argument. Reverse it and then return it from the…