Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

call function using if statement

I want to be able to call a function within an if statement.

For example:

var photo = "yes";

if (photo=="yes") {

    capturePhoto();

}

else {
  //do nothing
}; 

This does nothing though. The function is clearly defined above this if statement.

Edit: Wow, downboated to hell! capturePhoto(); was just an example function that didn't really need any more explanation in this scenario?

like image 942
jcrowson Avatar asked Nov 28 '22 03:11

jcrowson


1 Answers

That should work. Maybe capturePhoto() has a bug? Insert an alert() or console.log():

var photo = "yes";
if (photo == "yes") {
 alert("Thank you StackOverflow, you're a very big gift for all programmers!");
 capturePhoto();
} else {
  alert("StackOverflow.com must help me!");
}
like image 99
ComFreek Avatar answered Nov 30 '22 23:11

ComFreek