generate functionMon, 28 Nov 2022

Define a word as a sequence of consecutive English letters. Find the longest word from the given string.

const myString = 'Find the longest word from the given string.' const myStringArr = myString.split(' ') function longestWord(myStringArr) { let longestWord = '' for (let word of myStringArr) { if (word.length > longestWord.length) { longestWord = word } } return longestWord }

Generate More

Questions about programming?Chat with your personal AI assistant