Skip to main content

3 digit for loop

Would you believe that this is almost exactly the same as some JavaScript code that I found, that somebody actually wrote? Tell me, what's wrong with this code? Could you think of any more concise way to write it? All we need is the highest version number we can use to create the activex object without throwing an exception.
var curr = -1;
for (var n1 = 1; n1 >= 1 && curr == -1; --n1) {
    for (var n2 = 9; n2 >= 0 && curr == -1; --n2) {
        for (var n3 = 9; n3 >= 0 && curr == -1; --n3) {
            for (var n4 = 9; n4 >= 0 && curr == -1; --n4) {
                for (var n5 = 9; n5 >= 0 && curr == -1; --n5) {
                    var version = "" + n1 + n2 + n3 + "_" + n4 + n5;
                    try {
                        var versioned = new ActiveXObject("JavaPlugin." + version);
                        curr = new Number("" + n1 + n2 + n3);
                    }
                    catch (e) {
                        continue;
                    }
                }
            }
        }
    }
}
:-) :-) :-) Well, I thought it was funny.

Popular posts from this blog

What We're About

About UsMission Statement: We provide a product to make high performing software developers happy by giving them a chance to work in a more self-directed way on software that is more meaningful to them. Core Values (in priority order):Integrity: Honesty, trustworthiness, and faithfulnessPreparation: Research, planning, and goalsReputation: Branding, naming, presence, and networkingProfitability: Product salesProduction: Product development, ideas, online contentImprovement: Research and trainingSupport: Minimal overhead Who We Are
Isaac Serafino is a Software Architect in Omaha, Nebraska. He has a strong experience developing technology solutions. He has long had the dream to lead his own startup business.
Our ProductsSnap Screen™
More efficiently provide a safe environment for using electronic devices. Sends pictures of what is on the display at somewhat random times so user knows they could be observed at any time, but the supervisor does not need to be their watching over their sho…

The Invasion of the Developer Commandos™

I. Why Deploy Commandos? It's hard to find the best people to solve difficult problems. By deploying Developer Commandos™, you can get great software developed without needing to figure out how to find the software developers. II. What are Developer Commandos? Unlike an old fashioned developer, a commando works independently. They manage themselves so you won't need to. III. How Can You Deploy Commandos? A. Create a Project Use a project host like GitHub to create a shared workspace online. Commandos will be able to contribute to your software project through this workspace. B. Obtain Incentives Use a cryptocurrency exchange like Coinbase to purchase an amount of a cryptocurrency such as Ether. You will be able to use this cryptocurrency to provide an incentive for commandos. C. Post Opportunities Use a bounty network such as Gitcoin to post bounties. A bounty describes the software problem you need resolved, and allows you to attach a cryptocurrency incentive for resolving i…