Question: I am using JavaScript to try to animate a `div`. For some reason, my `div` doesn't keep going right `400px` in a loop every 2 seconds, it only moves once.

**The JavaScript:**

```
<script>
    function animate(name,dist,time) {
        $(name).animate({left:dist},time);
    }
    $(function() {
        setInterval(animate('.box1',400,800),2000);
    });
</script>  

```

**The HTML:**

```
<div class="box1"></div>

```

Answer: 
Without break statement it will continue to execute other statements too. by using break it exit from switch case after matched case.
The keyword `break` is needed to break out of each case of the switch statement.

<https://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html>

> 
> ...Each break statement terminates the enclosing switch statement.
>  Control flow continues with the first statement following the switch
>  block. The break statements are necessary because without them,
>  statements in switch blocks fall through: All statements after the
>  matching case label are executed in sequence, regardless of the
>  expression of subsequent case labels, until a break statement is
>  encountered
> 
> 
>