JavaScript Code:

Output:


        

Trace Table