SO-59148181
by David Thomas
HTML
<div id="myid">Some arbitrary text</div>
JavaScript
let words = ["color", "blue", "font-size", "100px"], // these have been parsed from a file and formatted
pairs = words.reduce(function(result, value, index, array) {
if (index % 2 === 0)
result.push(array.slice(index, index + 2));
return result;
}, []),
cssObj = Object.fromEntries(pairs);
$('#myid').css(cssObj);