Comment

Comment by goldenkey

I am scratching my head at how someone can write a blog post correcting code and leaving such egregious code as a revision. The last snippet of code is still busted and very cringeworthy

The proper way to do alternate behavior for the first iteration, would be this... It's O(n) versus the authors O(2n)

    if(attributeArray instanceof Array) { 
        if (attributeArray.length >= 1){
            // do something with attributeArray[0]
            for (var i = 1; i < attributeArray.length; ++i) 
                // do something different with attributeArray[index]
        }
    }
parent goldenkey 12 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton