location.replace() Not Working
launcherman08

Hello Repl!
I am creating a game, and the location.replace() in level1.js in source is not working. Can I have some help please?

You are viewing a single comment. View All
MatthewDoan1

(That's what I think from looking at your code, anyhow)

replace returns the modified string; the original string says the same.

launcherman08

@MatthewDoan1 Sorry Matthew, but when tested, the code did not work.

MatthewDoan1

@launcherman08 My bad, JavaScript's .replace() takes in two arguments - the string to be replaced, and the string to replace it with. Since I don't know what you're trying to do, that's all I can say for now.

MatthewDoan1

@launcherman08 Oops again, I now understand what you're trying to do. Just use this line:

I forked your repl and tested it, it should work.

launcherman08

@MatthewDoan1 I am trying to redirect the page to a different page.

MatthewDoan1

@launcherman08 Have you tried my code?

launcherman08

@MatthewDoan1 Yes, and it did not work.