In this trick, we will see how to find the longest word in a string or sentence using the javascript function code.
We will check each word one by one and count the length of characters and store it in a variable. Then we will compare all of them and print the longest word from the given string.
Find Longest Word in String with Reduce() Method
Find Longest Word in String with Sort() Method
Find Longest Word in String with For Loop
Being Tricky 😉