Driver program to test above function
let arr = [ " " , " " , " " , " " ] let n = arr . length ; let ans = commonPrefix ( arr , n ) ; if ( ans . length > 0 ) { document . write ( " " + ans ) ; } else { document . write ( " " ) ; }