On string concatenation of ES6

first of all, the interface looks like this:

clipboard.png

uses a frame and returns the selected id, array format.

but the string format is required in the background, and it is too troublesome to convert it with js, so ES6

is used here.
var iab2_result = `${this.iab2_1},${this.iab2_2},${this.iab2_3},${this.iab2_4},${this.iab2_5},${this.iab2_6}`

as shown above, the converted data is normal, as follows:

"2,3,69,71,144,145,225,224,222,339,213,210"

but you can choose at least one of this multi-check box. If the user chooses a data, that"s it

"2,,,,,,"

it must be bad to have so many commas. Is there any way to improve it?


let checklist= [];
checklist.push(this.iab2_1) //
let iab2_result  = checklist.join(',');

  

str.replace (/ (,) (?!\ w) / gjinger')

Menu