Code

Output

Explanation

Demos of $.map in jQuery.