Tell us what’s happening:Hey guys, so I an ext or less obtained the summary of mine algorithm. I’m just unsure what I can implement in the loop come loop with the worths of the array and also get the longest string’s length. Carry out I have to add another loop or an if maybe? ns just puzzled atm. Any kind of advice would certainly be helpful!

Thanks in breakthrough for the help!

RegardsMa3_str0

Your code so far

function findLongestWordLength(str) {let strArr = str.split();for(let i = 0;i Your internet browser information:

User agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0.

You are watching: Find the longest word in a string freecodecamp

Challenge: uncover the Longest native in a String

Link to the challenge:

*
sommos.net.org
*

sommos.net.org

Learn come code. Construct projects. Knife certifications.Since 2015, 40,000 graduates have obtained jobs at technology companies including Google, Apple, Amazon, and Microsoft.


ilenia might 29, 2020, 8:43am #2
Ma3_str0:

let loopLength = strArr.length;

now you are putting loopLength each time in ~ the size of current word

but you should compare the assorted word lengths to each various other to uncover out i beg your pardon is the longest

you are lacking that logic


Ma3_str0 might 29, 2020, 9:26am #3

Would i compare them in an if statement? Or how would i compare the lengths? cause that’s what’s largely confusing me.


Bam92 may 29, 2020, 9:31am #4

To deal with such a challenge, you require a little bit of time to think manually around the logic.

And if friend can, compose the pseudocode than analyze it in real-language code.

There’s not at every ONE unique method to think good, no. You simply need a little of reasonable in your thinking. You deserve to still refactor as plenty of times as you want.

Here’s my proposal for you:

split the param making use of (’ ") together separator (keep that in a var)set a var as the size asked v 0 (zero) as initial worth (let speak to it strL)loop v the split varif the existing str length > strL => strL = current str lengthreturn strL

This is simply one means you have the right to do it.

See more: Stanley M. Isaacs Neighborhood Center, Isaacs Center


1 choose
Ma3_str0 may 29, 2020, 12:30pm #5

Thanks because that the solution my guy I’ll try those steps. When I regimen in general when solving problems or structure a arbitrarily app, I gain impulsive and also I improv everything along the method and tinker later. But I’ve been trying to an initial plan in pseudo lately and it’s to be helping me slowly but surely! thanks again for the reply!


1 choose
Izge may 31, 2020, 4:54pm #6

this is to run fine in vscode however not ~ above the fcc pen. Please help

function findLongestWordLengt(str)

let bunch = str.split(" ");

let dogo = “”;

for ( let solitary of bunch)

if(single.length > dogo.length) dogo = single;

return str = dogo.length;

console.log(findLongestWordLengt(“The fast brown fox jumped over the lazy dog”));


ilenia may 31, 2020, 8:18pm #7

your function has a various name 보다 the one provided in the tests


1 like
Bam92 June 2, 2020, 10:46am #8

The duty name is FCC is this findLongestWordLength(), yours does not have h at the end.


1 choose
ilenia close up door June 1, 2021, 12:46pm #9
house Subsommos.nets FAQ/Guidelines state of company Privacy plan

Powered through Discourse, best viewed v JavaScript enabled