Bug in Louisiana Economic Development Ad?

ぐ巨炮叔叔 提交于 2019-12-11 05:14:58

问题


I was reading the June 2011 issue of Wired magazine the other day, and I came across an ad for Louisiana Economic Development, presumably written in ActionScript.

I originally thought that it was a clever ad, but after looking into it, it seems like there's a fairly obvious bug in the code.

Is it just me, or should that break be a return?


回答1:


I'd call it a bug, since the desired outcome would most likely be to navigate to the URL if any one of those interests is held and do nothing if none of them are. As such, I would change the logic to the following (ignoring for the moment the issues mentioned in the comment from scriptocalypse):

if (this.innovator.hasInterestIn(interest[i])){
    navigateToURL("www.OpportunityLouisiana.com/digital");
    return;
}

Of course, this wouldn't look as good in an ad, since the URL wouldn't be prominently displayed at the bottom of the code. Perhaps a better alternative would be to organize the logic in the loop like this:

if (this.innovator.hasInterestIn(interest[i])){
    break;
} else if (i == n-1){
    return;
}



回答2:


Wouldn't call it a bug as much as faulty logic...the break will get you out of the loop, but if you enter that function you're navigating to that URL, whether you're interested in all those things or not.




回答3:


Yep, that should be a return. Right now, as the code stands, navigatetoUrl will fire even if the user has none of the interests.




回答4:


The code only navigates to that page regardless of variables before the function and if this is the intention of the function then it is correct but badly implemented because the loop and everything before it are redundant. Perhaps the ad is a call for help, being that the code is faulty and that the company is looking to hire able developers to correct the mistakes of those already employed.



来源:https://stackoverflow.com/questions/6114684/bug-in-louisiana-economic-development-ad

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!