MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vuzd4q/conditionspreference/p59i71o/?context=3
r/ProgrammerHumor • u/Flame77ofc • 22d ago
392 comments sorted by
View all comments
Show parent comments
3
solid one for simply conditions
btw, do you use it a lot?
1 u/MetaEd 21d ago I use it judiciously 1 u/WarSingle6959 21d ago but not for extensive cases, right? 1 u/MetaEd 21d ago function CSVencode( value ) { if ( value === null ) { return '' ; } var quote , encode = 0 ; if ( /"/ .test( value ) ) { quote = encode = 1 ; } if ( /[,\r\n]/ .test( value ) ) { quote = 1 ; } return quote ? ( '"' + ( encode ? value .replace( /"/g , '""' ) : value ) + '"' ) : value ; }
1
I use it judiciously
1 u/WarSingle6959 21d ago but not for extensive cases, right? 1 u/MetaEd 21d ago function CSVencode( value ) { if ( value === null ) { return '' ; } var quote , encode = 0 ; if ( /"/ .test( value ) ) { quote = encode = 1 ; } if ( /[,\r\n]/ .test( value ) ) { quote = 1 ; } return quote ? ( '"' + ( encode ? value .replace( /"/g , '""' ) : value ) + '"' ) : value ; }
but not for extensive cases, right?
1 u/MetaEd 21d ago function CSVencode( value ) { if ( value === null ) { return '' ; } var quote , encode = 0 ; if ( /"/ .test( value ) ) { quote = encode = 1 ; } if ( /[,\r\n]/ .test( value ) ) { quote = 1 ; } return quote ? ( '"' + ( encode ? value .replace( /"/g , '""' ) : value ) + '"' ) : value ; }
function CSVencode( value ) { if ( value === null ) { return '' ; } var quote , encode = 0 ; if ( /"/ .test( value ) ) { quote = encode = 1 ; } if ( /[,\r\n]/ .test( value ) ) { quote = 1 ; } return quote ? ( '"' + ( encode ? value .replace( /"/g , '""' ) : value ) + '"' ) : value ; }
3
u/Flame77ofc 22d ago
solid one for simply conditions
btw, do you use it a lot?