Swap function
function swap ( str , i , j ) { let tempArr = str . split ( " " ) ; let temp = tempArr [ i ] ; tempArr [ i ] = tempArr [ j ] ; tempArr [ j ] = temp ; return ( tempArr ) . join ( " " ) ; }