Generation

generate functionMon, 14 Nov 2022

find the shortest text in an array of strings

function findShortest(arr) { let shortest = arr[0]; for (let word of arr) { if (word.length < shortest.length) { shortest = word; } } return shortest; } findShortest(['one', 'two', 'three', 'four']);

Javascript
Generate More

Want to kickstart your project?Use the new AI Studio to create your code