The code looks fine to me (except you don't need the ; at the end of the last line).  Check your error log; perhaps the browser thinks capturePhoto is not defined for some reason.  You can also add alert statements to make sure the code is actually running:
var photo = "yes";
alert('Entering if statement');
if (photo=="yes") {
    alert('then');
    capturePhoto();
} else {
    alert('else');
    //do nothing
}
When you encounter a situation where it seems like a fundamental language feature is not working, get some more information about what is going on.  It is almost never the platform's fault.  It is occasionally a misunderstanding of how the feature works (e.g. why does parseInt('031') == 25 ?).  It is usually a violation of an assumption you're making about the code that isn't holding up because of a problem elsewhere.