How to set CSS custom property in JavaScript

DOM
By Jad Joubran · 
Last updated Mar 12, 2018
:root {
  --primary-color: #ececec;
}
document.documentElement.style.setProperty("--primary-color", "#000000");