JSFiddle - React, Tailwind, and code Playground

by LuckyCat

JavaScript

/* 5 \ task04

'use strict';

// Написать функцию, которая принимает строку, а возвращает длину самого короткого слова
function funcName(str) {
    
}

Например:  
funcName("bitcoin take over the world maybe who knows perhaps"),                3
funcName("turns out random test cases are easier than writing out basic ones"), 3



// Solutions: 

*/


function funcName(str) {
    /*str = str.split(' ').map(word => word.length);
    console.log(Math.min(...str));
    return Math.min(...str);*/
    
    
    return Math.min(...str.split(' ').map(word => word.length));
}

// Например:  
console.log(
  funcName("bitcoin take over the world maybe who knows perhaps"), // 3
  funcName("turns o random test cases are easier than writing out basic ones") //  1
);