Redirecting script on webpage with delay location.redirect not working javascript

This is in script tag in my base html

 const arraypathname = [`array of paths`]

 var i = 0; 

```
this function loops array of paths and should redirect on every path url from array  with delay
```

function redirectFunc(){
  setTimeout(function() {  
    var path_to_redirect = arraypathname[i];
    window.location.redirect(path_to_redirect);
    
        ```
this doesn work when i used alert() with path it work and every 3 sec i get alert with different path. Why windows.location.replace not working?
        ```
    i++;             
    if (i < 10) {         
      redirectFunc();      
    }                      
  }, 3000)
  
}

```
i have a base.html file witch is used on every page on my site and i want to do presentation script witch will loop through all paths on web with delay
```

i dont now why its not working like that when i used alert(path_to_redirect) every
3 seconds it alert me with url