I'm trying to change one of two background colours of a gradient via Javascript. The color is scroll dependent. Somehow a single color works but not a gradient.
const [red, green, blue] = [0, 200, 0];
const hasGradient = document.querySelector('.has-gradient');
window.addEventListener('scroll', () => {
let y = 1 + (window.scrollY || window.pageYOffset) / 150;
y = y < 1 ? 1 : y
const [r, g, b] = [red/y, green/y, blue/y].map(Math.round);
hasGradient.style.background = `linear-gradient(rgb(${r}, ${g}, ${b}), rgb(255,0,0));`;
console.log(`linear-gradient(rgb(${r}, ${g}, ${b}), rgb(255,0,0))`)
});
Thx for any input!