I'm trying to fluctuate the variable "z" by 0.1 between the two ranges of 0 and 2 continuously. When it hits the max of 2, I want the variable "z" to decrement. And when it hits the min of 0, I want the variable "z" to increment. So far, all my code does is return the number 1.
NOTE: I'm also using doing this on canvas-sketch by github.com/mattdesl
let z = 1;
let count = 0.1;
setInterval(function(){
if(z == 2) count *= -1;
if(z == 0) count *= +1;
return z += count;
}, 1000);
console.log(z);