JavaScript Function for 'Error Handling' NaN Value Replacement