Is the modulo function used just to be difficult?

The point of all of that code is just to say 1, 2, 3, 4. It seems to me there has to be a much clearer and simpler way to do this where the code would be much more readable. I understand the functions and how modulo works, it seems like it’s written this way just to be difficult. Is there some reason I’m not getting that it couldn’t be written more simply?

what code? If you refer to code, including it can be very useful.

If this is an exercise, please also include exercise url

  nextGP() {
    let current = this.state.currentGP;
    let next = ++current % GUINEAPATHS.length;
    this.setState({ currentGP: next });

  componentDidMount() {
    this.interval = setInterval(this.nextGP, 1000);

  componentWillUnmount() {

Why is this to complicated? I don’t see the problem, the modulo operator ensures that after we had all images in array, it goes back to the first image

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.