Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

codewars js Shortest Word

function findShort(s) {
    var arr = s.split(' ');
    var smallest = arr[0];
    for (var i = 0; i < arr.length; i++) {
        if (arr[i].length < smallest.length) {
            smallest = arr[i];
        }
    }
    return smallest.length;
}
 
PREVIOUS NEXT
Tagged: #codewars #js #Shortest #Word
ADD COMMENT
Topic
Name
1+2 =