function length(str) {
        // undefined inputs always return undefined
        if (typeof str === 'undefined') {
            return undefined;
        }

        return stringToArray(str).length;
    }
length of a string
@param {String} str - string
@returns {Number} The number of characters in the string