Untitled

mail@pastecode.io avatar
unknown
javascript
2 years ago
323 B
3
Indexable
Never
var lengthOfLastWord = function(s) {
    s = s.trim()
    let length = 0;
    let windowStart = 0;
    
    for(windowEnd = 0; windowEnd < s.length  ; windowEnd++) {
        length += 1;
        if(s[windowEnd] == ' ') {
            windowStart = windowEnd;
            length =0;
        }
    }
    
    return length;
};