Hey guys, so this is what I managed to do on my own, I can’t seem to find a way how I count the length of the words… any advice for me?
**Your code so far**
function findLongestWordLength(str) {
const sentence = str.split()
const word = str.split(" ")
for (let i = 0; i < word.length; i++) {
}
return str.length;
}
findLongestWordLength("The quick brown fox jumped over the lazy dog");
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36
But I didn’t ask you to explain it in javascript, I asked you to explain it in English. Looking at that sentence, what would you need to do to determine the longest word? You can’t just say “I would look at it and see that ‘sentence’ is the longest word” because that’s not really what is going on in your brain. What method would you use to make sure you find the longest word?
And what is that “something” you want to compare? What is the ultimate goal of this function?
I need to wrap this up. I think you need to make a good faith effort at coding this and if you can’t get it to work you can paste your code back in here. But you can’t just have an empty for loop and expect us to tell you what to put in there.
Okay I’ll try to compare the characters between the words I guess thats what I need to do.
but just thinking about this my brain does a lot of stuff automatically but translating it into programming is a different story.
That is what programming is. Translating stuff from your brain into code. But you have to know how to do it in your brain first before you can translate.
And you may think your brain is doing stuff automatically, but if you really think about it, you are going through steps to get the answer just like a computer would.
ok so for example now I have list of words length, 4,5,6,3,4 for example.
Now, How can I say that 6 is bigger than the rest? so i need to say if 6 is bigger than something to print it, but how do i tell the computer that 6 is the biggest…