JavaScript Function Skipping
I have a script that should run a function every 5 seconds depending on what one was previously run however it seems to be skipping every second one.
let i = 0;
function testOne()
{
$("#two").fadeOut().css("display","none");
$("#three").fadeOut().css("display","none");
$("#four").fadeOut().css("display","none");
$("#five").fadeOut().css("display","none");
$("#one").fadeIn().css("display","block");
$("#iOne").addClass("btn-active");
$("#iTwo").removeClass("btn-active");
$("#iThree").removeClass("btn-active");
$("#iFour").removeClass("btn-active");
$("#iFive").removeClass("btn-active");
i++;
}
function testTwo() {
$("#one").fadeOut().css("display","none");
$("#three").fadeOut().css("display","none");
$("#four").fadeOut().css("display","none");
$("#five").fadeOut().css("display","none");
$("#two").fadeIn().css("display","block");
$("#iTwo").addClass("btn-active");
$("#iOne").removeClass("btn-active");
$("#iThree").removeClass("btn-active");
$("#iFour").removeClass("btn-active");
$("#iFive").removeClass("btn-active");
i++;
}
function testThree() {
$("#one").fadeOut().css("display","none");
$("#two").fadeOut().css("display","none");
$("#four").fadeOut().css("display","none");
$("#five").fadeOut().css("display","none");
$("#three").fadeIn().css("display","block");
$("#iThree").addClass("btn-active");
$("#iTwo").removeClass("btn-active");
$("#iOne").removeClass("btn-active");
$("#iFour").removeClass("btn-active");
$("#iFive").removeClass("btn-active");
i++;
}
function testFour() {
$("#one").fadeOut().css("display","none");
$("#two").fadeOut().css("display","none");
$("#three").fadeOut().css("display","none");
$("#five").fadeOut().css("display","none");
$("#four").fadeIn().css("display","block");
$("#iFour").addClass("btn-active");
$("#iTwo").removeClass("btn-active");
$("#iThree").removeClass("btn-active");
$("#iOne").removeClass("btn-active");
$("#iFive").removeClass("btn-active");
i++;
}
function testFive() {
$("#one").fadeOut().css("display","none");
$("#two").fadeOut().css("display","none");
$("#three").fadeOut().css("display","none");
$("#four").fadeOut().css("display","none");
$("#five").fadeIn().css("display","block");
$("#iFive").addClass("btn-active");
$("#iTwo").removeClass("btn-active");
$("#iThree").removeClass("btn-active");
$("#iFour").removeClass("btn-active");
$("#iOne").removeClass("btn-active");
i = 0;
}
window.setInterval(function()
{
if(i === 0) {
testOne();
i++;
} else if (i === 1) {
testTwo();
i++;
} else if (i === 2) {
testThree();
i++;
} else if (i === 3) {
testFour();
i++;
} else if (i === 4) {
testFive();
let i = 0;
}
}, 5000);
The functions are displayed after "let i = 0" however I chose not to put them in as they are too long. All they do is run some jQuery code before i++; or let i = 0; on the fifth function.
Do you know why this could be the issue?
Full JS Code - https://hastebin.com/icalefafoy.js
- Ben J
javascript jquery
|
show 1 more comment
I have a script that should run a function every 5 seconds depending on what one was previously run however it seems to be skipping every second one.
let i = 0;
function testOne()
{
$("#two").fadeOut().css("display","none");
$("#three").fadeOut().css("display","none");
$("#four").fadeOut().css("display","none");
$("#five").fadeOut().css("display","none");
$("#one").fadeIn().css("display","block");
$("#iOne").addClass("btn-active");
$("#iTwo").removeClass("btn-active");
$("#iThree").removeClass("btn-active");
$("#iFour").removeClass("btn-active");
$("#iFive").removeClass("btn-active");
i++;
}
function testTwo() {
$("#one").fadeOut().css("display","none");
$("#three").fadeOut().css("display","none");
$("#four").fadeOut().css("display","none");
$("#five").fadeOut().css("display","none");
$("#two").fadeIn().css("display","block");
$("#iTwo").addClass("btn-active");
$("#iOne").removeClass("btn-active");
$("#iThree").removeClass("btn-active");
$("#iFour").removeClass("btn-active");
$("#iFive").removeClass("btn-active");
i++;
}
function testThree() {
$("#one").fadeOut().css("display","none");
$("#two").fadeOut().css("display","none");
$("#four").fadeOut().css("display","none");
$("#five").fadeOut().css("display","none");
$("#three").fadeIn().css("display","block");
$("#iThree").addClass("btn-active");
$("#iTwo").removeClass("btn-active");
$("#iOne").removeClass("btn-active");
$("#iFour").removeClass("btn-active");
$("#iFive").removeClass("btn-active");
i++;
}
function testFour() {
$("#one").fadeOut().css("display","none");
$("#two").fadeOut().css("display","none");
$("#three").fadeOut().css("display","none");
$("#five").fadeOut().css("display","none");
$("#four").fadeIn().css("display","block");
$("#iFour").addClass("btn-active");
$("#iTwo").removeClass("btn-active");
$("#iThree").removeClass("btn-active");
$("#iOne").removeClass("btn-active");
$("#iFive").removeClass("btn-active");
i++;
}
function testFive() {
$("#one").fadeOut().css("display","none");
$("#two").fadeOut().css("display","none");
$("#three").fadeOut().css("display","none");
$("#four").fadeOut().css("display","none");
$("#five").fadeIn().css("display","block");
$("#iFive").addClass("btn-active");
$("#iTwo").removeClass("btn-active");
$("#iThree").removeClass("btn-active");
$("#iFour").removeClass("btn-active");
$("#iOne").removeClass("btn-active");
i = 0;
}
window.setInterval(function()
{
if(i === 0) {
testOne();
i++;
} else if (i === 1) {
testTwo();
i++;
} else if (i === 2) {
testThree();
i++;
} else if (i === 3) {
testFour();
i++;
} else if (i === 4) {
testFive();
let i = 0;
}
}, 5000);
The functions are displayed after "let i = 0" however I chose not to put them in as they are too long. All they do is run some jQuery code before i++; or let i = 0; on the fifth function.
Do you know why this could be the issue?
Full JS Code - https://hastebin.com/icalefafoy.js
- Ben J
javascript jquery
let i = 0;
->i = 0;
, otherwise looks good, maybe you call the whole code more than once?
– Jonas Wilms
Nov 20 '18 at 18:57
I tried that but still the same error.
– Ben J
Nov 20 '18 at 18:59
1
It works just fine aside from what Jonas pointed out. I'm unable to duplicate jsfiddle.net/pzejvrfc/1
– zfrisch
Nov 20 '18 at 18:59
Forgot to mention. It takes double the time the setInterval should take before skipping the code.
– Ben J
Nov 20 '18 at 19:00
@BenJ Okay, but the function isn't or is skipping for you? You have to be more specific with what the problem is - and since we can't duplicate, please show us more of your code.
– zfrisch
Nov 20 '18 at 19:03
|
show 1 more comment
I have a script that should run a function every 5 seconds depending on what one was previously run however it seems to be skipping every second one.
let i = 0;
function testOne()
{
$("#two").fadeOut().css("display","none");
$("#three").fadeOut().css("display","none");
$("#four").fadeOut().css("display","none");
$("#five").fadeOut().css("display","none");
$("#one").fadeIn().css("display","block");
$("#iOne").addClass("btn-active");
$("#iTwo").removeClass("btn-active");
$("#iThree").removeClass("btn-active");
$("#iFour").removeClass("btn-active");
$("#iFive").removeClass("btn-active");
i++;
}
function testTwo() {
$("#one").fadeOut().css("display","none");
$("#three").fadeOut().css("display","none");
$("#four").fadeOut().css("display","none");
$("#five").fadeOut().css("display","none");
$("#two").fadeIn().css("display","block");
$("#iTwo").addClass("btn-active");
$("#iOne").removeClass("btn-active");
$("#iThree").removeClass("btn-active");
$("#iFour").removeClass("btn-active");
$("#iFive").removeClass("btn-active");
i++;
}
function testThree() {
$("#one").fadeOut().css("display","none");
$("#two").fadeOut().css("display","none");
$("#four").fadeOut().css("display","none");
$("#five").fadeOut().css("display","none");
$("#three").fadeIn().css("display","block");
$("#iThree").addClass("btn-active");
$("#iTwo").removeClass("btn-active");
$("#iOne").removeClass("btn-active");
$("#iFour").removeClass("btn-active");
$("#iFive").removeClass("btn-active");
i++;
}
function testFour() {
$("#one").fadeOut().css("display","none");
$("#two").fadeOut().css("display","none");
$("#three").fadeOut().css("display","none");
$("#five").fadeOut().css("display","none");
$("#four").fadeIn().css("display","block");
$("#iFour").addClass("btn-active");
$("#iTwo").removeClass("btn-active");
$("#iThree").removeClass("btn-active");
$("#iOne").removeClass("btn-active");
$("#iFive").removeClass("btn-active");
i++;
}
function testFive() {
$("#one").fadeOut().css("display","none");
$("#two").fadeOut().css("display","none");
$("#three").fadeOut().css("display","none");
$("#four").fadeOut().css("display","none");
$("#five").fadeIn().css("display","block");
$("#iFive").addClass("btn-active");
$("#iTwo").removeClass("btn-active");
$("#iThree").removeClass("btn-active");
$("#iFour").removeClass("btn-active");
$("#iOne").removeClass("btn-active");
i = 0;
}
window.setInterval(function()
{
if(i === 0) {
testOne();
i++;
} else if (i === 1) {
testTwo();
i++;
} else if (i === 2) {
testThree();
i++;
} else if (i === 3) {
testFour();
i++;
} else if (i === 4) {
testFive();
let i = 0;
}
}, 5000);
The functions are displayed after "let i = 0" however I chose not to put them in as they are too long. All they do is run some jQuery code before i++; or let i = 0; on the fifth function.
Do you know why this could be the issue?
Full JS Code - https://hastebin.com/icalefafoy.js
- Ben J
javascript jquery
I have a script that should run a function every 5 seconds depending on what one was previously run however it seems to be skipping every second one.
let i = 0;
function testOne()
{
$("#two").fadeOut().css("display","none");
$("#three").fadeOut().css("display","none");
$("#four").fadeOut().css("display","none");
$("#five").fadeOut().css("display","none");
$("#one").fadeIn().css("display","block");
$("#iOne").addClass("btn-active");
$("#iTwo").removeClass("btn-active");
$("#iThree").removeClass("btn-active");
$("#iFour").removeClass("btn-active");
$("#iFive").removeClass("btn-active");
i++;
}
function testTwo() {
$("#one").fadeOut().css("display","none");
$("#three").fadeOut().css("display","none");
$("#four").fadeOut().css("display","none");
$("#five").fadeOut().css("display","none");
$("#two").fadeIn().css("display","block");
$("#iTwo").addClass("btn-active");
$("#iOne").removeClass("btn-active");
$("#iThree").removeClass("btn-active");
$("#iFour").removeClass("btn-active");
$("#iFive").removeClass("btn-active");
i++;
}
function testThree() {
$("#one").fadeOut().css("display","none");
$("#two").fadeOut().css("display","none");
$("#four").fadeOut().css("display","none");
$("#five").fadeOut().css("display","none");
$("#three").fadeIn().css("display","block");
$("#iThree").addClass("btn-active");
$("#iTwo").removeClass("btn-active");
$("#iOne").removeClass("btn-active");
$("#iFour").removeClass("btn-active");
$("#iFive").removeClass("btn-active");
i++;
}
function testFour() {
$("#one").fadeOut().css("display","none");
$("#two").fadeOut().css("display","none");
$("#three").fadeOut().css("display","none");
$("#five").fadeOut().css("display","none");
$("#four").fadeIn().css("display","block");
$("#iFour").addClass("btn-active");
$("#iTwo").removeClass("btn-active");
$("#iThree").removeClass("btn-active");
$("#iOne").removeClass("btn-active");
$("#iFive").removeClass("btn-active");
i++;
}
function testFive() {
$("#one").fadeOut().css("display","none");
$("#two").fadeOut().css("display","none");
$("#three").fadeOut().css("display","none");
$("#four").fadeOut().css("display","none");
$("#five").fadeIn().css("display","block");
$("#iFive").addClass("btn-active");
$("#iTwo").removeClass("btn-active");
$("#iThree").removeClass("btn-active");
$("#iFour").removeClass("btn-active");
$("#iOne").removeClass("btn-active");
i = 0;
}
window.setInterval(function()
{
if(i === 0) {
testOne();
i++;
} else if (i === 1) {
testTwo();
i++;
} else if (i === 2) {
testThree();
i++;
} else if (i === 3) {
testFour();
i++;
} else if (i === 4) {
testFive();
let i = 0;
}
}, 5000);
The functions are displayed after "let i = 0" however I chose not to put them in as they are too long. All they do is run some jQuery code before i++; or let i = 0; on the fifth function.
Do you know why this could be the issue?
Full JS Code - https://hastebin.com/icalefafoy.js
- Ben J
javascript jquery
javascript jquery
edited Nov 20 '18 at 19:08
zfrisch
4,57511024
4,57511024
asked Nov 20 '18 at 18:54
Ben JBen J
63
63
let i = 0;
->i = 0;
, otherwise looks good, maybe you call the whole code more than once?
– Jonas Wilms
Nov 20 '18 at 18:57
I tried that but still the same error.
– Ben J
Nov 20 '18 at 18:59
1
It works just fine aside from what Jonas pointed out. I'm unable to duplicate jsfiddle.net/pzejvrfc/1
– zfrisch
Nov 20 '18 at 18:59
Forgot to mention. It takes double the time the setInterval should take before skipping the code.
– Ben J
Nov 20 '18 at 19:00
@BenJ Okay, but the function isn't or is skipping for you? You have to be more specific with what the problem is - and since we can't duplicate, please show us more of your code.
– zfrisch
Nov 20 '18 at 19:03
|
show 1 more comment
let i = 0;
->i = 0;
, otherwise looks good, maybe you call the whole code more than once?
– Jonas Wilms
Nov 20 '18 at 18:57
I tried that but still the same error.
– Ben J
Nov 20 '18 at 18:59
1
It works just fine aside from what Jonas pointed out. I'm unable to duplicate jsfiddle.net/pzejvrfc/1
– zfrisch
Nov 20 '18 at 18:59
Forgot to mention. It takes double the time the setInterval should take before skipping the code.
– Ben J
Nov 20 '18 at 19:00
@BenJ Okay, but the function isn't or is skipping for you? You have to be more specific with what the problem is - and since we can't duplicate, please show us more of your code.
– zfrisch
Nov 20 '18 at 19:03
let i = 0;
-> i = 0;
, otherwise looks good, maybe you call the whole code more than once?– Jonas Wilms
Nov 20 '18 at 18:57
let i = 0;
-> i = 0;
, otherwise looks good, maybe you call the whole code more than once?– Jonas Wilms
Nov 20 '18 at 18:57
I tried that but still the same error.
– Ben J
Nov 20 '18 at 18:59
I tried that but still the same error.
– Ben J
Nov 20 '18 at 18:59
1
1
It works just fine aside from what Jonas pointed out. I'm unable to duplicate jsfiddle.net/pzejvrfc/1
– zfrisch
Nov 20 '18 at 18:59
It works just fine aside from what Jonas pointed out. I'm unable to duplicate jsfiddle.net/pzejvrfc/1
– zfrisch
Nov 20 '18 at 18:59
Forgot to mention. It takes double the time the setInterval should take before skipping the code.
– Ben J
Nov 20 '18 at 19:00
Forgot to mention. It takes double the time the setInterval should take before skipping the code.
– Ben J
Nov 20 '18 at 19:00
@BenJ Okay, but the function isn't or is skipping for you? You have to be more specific with what the problem is - and since we can't duplicate, please show us more of your code.
– zfrisch
Nov 20 '18 at 19:03
@BenJ Okay, but the function isn't or is skipping for you? You have to be more specific with what the problem is - and since we can't duplicate, please show us more of your code.
– zfrisch
Nov 20 '18 at 19:03
|
show 1 more comment
2 Answers
2
active
oldest
votes
You increment i
twice, once in the interval code and once in the function itself:
function testOne() {
//...
i++
}
//...
testOne();
i++
just don't do that.
Ah I see now. Thank you. ISSUE FIXED
– Ben J
Nov 20 '18 at 19:14
add a comment |
You're incrementing the variable i
twice on each iteration of your interval, once in the function you call and once in the interval function itself, which is why it's skipping. Remove the i++
from your other functions.
let i = 0;
function testOne()
{
console.log("one");
}
function testTwo() {
console.log("two");
}
function testThree() {
console.log("three");
}
function testFour() {
console.log("four");
}
function testFive() {
console.log("five");
}
window.setInterval(function()
{
if(i === 0) {
testOne();
i++;
} else if (i === 1) {
testTwo();
i++;
} else if (i === 2) {
testThree();
i++;
} else if (i === 3) {
testFour();
i++;
} else if (i === 4) {
testFive();
let i = 0;
}
}, 5000);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53399704%2fjavascript-function-skipping%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You increment i
twice, once in the interval code and once in the function itself:
function testOne() {
//...
i++
}
//...
testOne();
i++
just don't do that.
Ah I see now. Thank you. ISSUE FIXED
– Ben J
Nov 20 '18 at 19:14
add a comment |
You increment i
twice, once in the interval code and once in the function itself:
function testOne() {
//...
i++
}
//...
testOne();
i++
just don't do that.
Ah I see now. Thank you. ISSUE FIXED
– Ben J
Nov 20 '18 at 19:14
add a comment |
You increment i
twice, once in the interval code and once in the function itself:
function testOne() {
//...
i++
}
//...
testOne();
i++
just don't do that.
You increment i
twice, once in the interval code and once in the function itself:
function testOne() {
//...
i++
}
//...
testOne();
i++
just don't do that.
answered Nov 20 '18 at 19:07
community wiki
Jonas Wilms
Ah I see now. Thank you. ISSUE FIXED
– Ben J
Nov 20 '18 at 19:14
add a comment |
Ah I see now. Thank you. ISSUE FIXED
– Ben J
Nov 20 '18 at 19:14
Ah I see now. Thank you. ISSUE FIXED
– Ben J
Nov 20 '18 at 19:14
Ah I see now. Thank you. ISSUE FIXED
– Ben J
Nov 20 '18 at 19:14
add a comment |
You're incrementing the variable i
twice on each iteration of your interval, once in the function you call and once in the interval function itself, which is why it's skipping. Remove the i++
from your other functions.
let i = 0;
function testOne()
{
console.log("one");
}
function testTwo() {
console.log("two");
}
function testThree() {
console.log("three");
}
function testFour() {
console.log("four");
}
function testFive() {
console.log("five");
}
window.setInterval(function()
{
if(i === 0) {
testOne();
i++;
} else if (i === 1) {
testTwo();
i++;
} else if (i === 2) {
testThree();
i++;
} else if (i === 3) {
testFour();
i++;
} else if (i === 4) {
testFive();
let i = 0;
}
}, 5000);
add a comment |
You're incrementing the variable i
twice on each iteration of your interval, once in the function you call and once in the interval function itself, which is why it's skipping. Remove the i++
from your other functions.
let i = 0;
function testOne()
{
console.log("one");
}
function testTwo() {
console.log("two");
}
function testThree() {
console.log("three");
}
function testFour() {
console.log("four");
}
function testFive() {
console.log("five");
}
window.setInterval(function()
{
if(i === 0) {
testOne();
i++;
} else if (i === 1) {
testTwo();
i++;
} else if (i === 2) {
testThree();
i++;
} else if (i === 3) {
testFour();
i++;
} else if (i === 4) {
testFive();
let i = 0;
}
}, 5000);
add a comment |
You're incrementing the variable i
twice on each iteration of your interval, once in the function you call and once in the interval function itself, which is why it's skipping. Remove the i++
from your other functions.
let i = 0;
function testOne()
{
console.log("one");
}
function testTwo() {
console.log("two");
}
function testThree() {
console.log("three");
}
function testFour() {
console.log("four");
}
function testFive() {
console.log("five");
}
window.setInterval(function()
{
if(i === 0) {
testOne();
i++;
} else if (i === 1) {
testTwo();
i++;
} else if (i === 2) {
testThree();
i++;
} else if (i === 3) {
testFour();
i++;
} else if (i === 4) {
testFive();
let i = 0;
}
}, 5000);
You're incrementing the variable i
twice on each iteration of your interval, once in the function you call and once in the interval function itself, which is why it's skipping. Remove the i++
from your other functions.
let i = 0;
function testOne()
{
console.log("one");
}
function testTwo() {
console.log("two");
}
function testThree() {
console.log("three");
}
function testFour() {
console.log("four");
}
function testFive() {
console.log("five");
}
window.setInterval(function()
{
if(i === 0) {
testOne();
i++;
} else if (i === 1) {
testTwo();
i++;
} else if (i === 2) {
testThree();
i++;
} else if (i === 3) {
testFour();
i++;
} else if (i === 4) {
testFive();
let i = 0;
}
}, 5000);
let i = 0;
function testOne()
{
console.log("one");
}
function testTwo() {
console.log("two");
}
function testThree() {
console.log("three");
}
function testFour() {
console.log("four");
}
function testFive() {
console.log("five");
}
window.setInterval(function()
{
if(i === 0) {
testOne();
i++;
} else if (i === 1) {
testTwo();
i++;
} else if (i === 2) {
testThree();
i++;
} else if (i === 3) {
testFour();
i++;
} else if (i === 4) {
testFive();
let i = 0;
}
}, 5000);
let i = 0;
function testOne()
{
console.log("one");
}
function testTwo() {
console.log("two");
}
function testThree() {
console.log("three");
}
function testFour() {
console.log("four");
}
function testFive() {
console.log("five");
}
window.setInterval(function()
{
if(i === 0) {
testOne();
i++;
} else if (i === 1) {
testTwo();
i++;
} else if (i === 2) {
testThree();
i++;
} else if (i === 3) {
testFour();
i++;
} else if (i === 4) {
testFive();
let i = 0;
}
}, 5000);
answered Nov 20 '18 at 19:10
zfrischzfrisch
4,57511024
4,57511024
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53399704%2fjavascript-function-skipping%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
let i = 0;
->i = 0;
, otherwise looks good, maybe you call the whole code more than once?– Jonas Wilms
Nov 20 '18 at 18:57
I tried that but still the same error.
– Ben J
Nov 20 '18 at 18:59
1
It works just fine aside from what Jonas pointed out. I'm unable to duplicate jsfiddle.net/pzejvrfc/1
– zfrisch
Nov 20 '18 at 18:59
Forgot to mention. It takes double the time the setInterval should take before skipping the code.
– Ben J
Nov 20 '18 at 19:00
@BenJ Okay, but the function isn't or is skipping for you? You have to be more specific with what the problem is - and since we can't duplicate, please show us more of your code.
– zfrisch
Nov 20 '18 at 19:03