I am such a great programmer

I wrote a function to get the length of pretty much anything in both Python and JavaScript. It is really great, some of my best work ever. It does it all in a mere four lines. I will be updating my active projects to use this fantastic work. Since it is so great and everyone should be able to use it, I have posted the code for both languages below. Who knows, perhaps programming languages will take this code and implement it into the core language, then we would not have to rely on us remembering the requirement of putting in any of our projects that need such an ability! 😀

Python

def len(item):
    i = 0
    for char in item:
        i += 1
    return i

JavaScript

function len(item) {
    i = 0;
    (for char in item) {
        i += 1;
    }
    return i;
};

I told you, I am such a great programmer. 😀

Advertisements

6 thoughts on “I am such a great programmer

    1. I updated the post to clarify what language each snippet is in, but yes the second one is JavaScript. JS and Python look alike sometimes, this being one of them. 😛

Comments are closed.