My website doesn’t respond after this Js code

Hello Everybody,

I am having a few challenges on my website. It happened after I inputed these javascript lines of codes:

for (var counter = 1; counter < 3; counter++) {

            function nextPortfolio () { 
                     document.getElementById (‘portfolio’).src = ‘image’  + counter + ‘.jpg’;
   }

}

I input that same code again but this time its a decrement (counter- -), that when my website started not responding…

I NEED HELP PLEASE

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Is the code above the one that breaks your page, or is it a different loop with a decrement? If so, could you please share the code taht causes the failure.

if the code is exactly what you posted, javascript fails when it encounters the fancy quotes

Edit: You also have a space between the document.getElementById and the parentheses (). But I’m not sure if that is the exact code you have or not.

I would imagine you have to change the var to a let as well.