How does setTimeout work? : <p>-so i am obviously trying to get two functions to run automatically whilst on a timer using setTimeout. However i am not to sure how it works. All i can see when i search it up is it in a function. so how do i have it outside a function?</p>

<pre><code>function ChangeImage() {
    if(position &lt; TrafficL.length) {
    document.getElementById("myImage").src = TrafficL[position];
    position++
    }
}
function RestartPos() {
    if (position==3)
    document.getElementById("myImage").src = TrafficL["position"]
    position=0


    var setTimeout = (ChangeImage(),1500)
    var setTimeout = (RestartPos(),6000) 
</code></pre>
