-1

Need to run helloWorld() after execution of dragTrack() function. But helloWorld is not being called after dragTrack.

dragTrack(function(){
    helloWorld();
});

function dragTrack() {
    alert('first');
}

function helloWorld() {
    alert('second');
}
2
  • dragTrack accepts no parameters ? Commented Jan 11, 2016 at 6:53
  • You should first research and than ask questions ,,, refer these answers stackoverflow.com/questions/18514504/… Commented Jan 11, 2016 at 7:04

2 Answers 2

7

You are passing a function as argument, but dragTrack need to be changed to accept the callback and to invoke it

dragTrack(helloWorld);

function dragTrack(callback) {
  alert('first');
  if (callback) {
    callback();
  }
}

function helloWorld() {
  alert('second');
}

Sign up to request clarification or add additional context in comments.

Comments

0

You are passing helloWorld() as an argument in your dragTrack() call, but you aren't processing it. Your dragTrack function needs a callback Parameter, so you can use your helloWorld() function as an Argument.

Comments

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.