Explanation of console.log to show results of function