0

I want to change the value of something variable in the all()`

let something = true;
function all(){
     alert("something");
}

Now I want to insert something variable in all setInterval() function and in all() How should I do this all

setInterval(all, 1000);
3
  • Do you want to pass parameter to all method? Commented Jul 10, 2020 at 5:20
  • Add an argument setInterval(()=>{all(somthing)},1000); Commented Jul 10, 2020 at 5:22
  • 1
    Don't alert in a loop Commented Jul 10, 2020 at 5:29

1 Answer 1

3
function all(message)
{
    alert(message);
}

setInterval(all, 1000, "hello world");
Sign up to request clarification or add additional context in comments.

5 Comments

I never notice that version! Too bad we cannot do setInterval(all, 1000, new Date()); to make a clock
You can just get the time from within the function.
I know. But still
console.log is good to check your answer's functionality easily, you can keep @mplungjan 's edit ;)
Thanks a lot for answering me on time

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.