Arrow function in Javascript - Brown Surfing

Arrow function in Javascript

Posted on: July 14th, 2022
By: Efrain Lemus

let fadeOut = (elem, cycles = 4, time = 100) => {
  
    // 1 seconds equals 1000 milliseconds
    
    // Assume opacity starts at 1
    for(let i = 0; i < cycles; i++) {
      setTimeout(() => {
        // TODO: your going to adjust the opacity
        elem.style.opacity -= .05/cycles
        // elem.style.opacity -= 1/cycles
      }, time);
    }
}

Have any questions or comments? Write them below!


Leave a Reply

Your email address will not be published.