More efficiently scripting multiple variables for same widget

Sorry to bother you all, but I was writing a small script for my template (which does work as it is), but I am no coder and was wondering if there was a more efficient way of doing this:

setVar('ParaPanel_1', 'Par', '3')
setVar('ParaPanel_1', 'Col', '#f388da')
setVar('ParaPanel_1', 'Hidden', '0')
setVar('ParaPanel_1', 'BgCol', '#9e9e9e38')

where you are setting multiple variables for the same widget?

Will be repeating this multiple times across the script for different widgets and just wanted to query if there was a better way of scripting this.

Thanks very much for any assistance!

var settings = {
  Par: 3,
  Col: '#f388da',
  Hidden: 0,
  BgCol: '#9e9e9e38'
}
for (var key in settings) {
  setVar('ParaPanel_1',  key, settings[key])
}
1 Like

Thanks so much Jean-Emmanuel, exactly what I was looking for, much better!