Javascript Challenges - Longest Word

preview_player
Показать описание
Javascript Challenges - Longest Word

COUPONS BELOW!!!!!!

REACT

JAVASCRIPT COURSE

BOOTSTRAP COURSE

IN DEPTH HTML AND CSS

RESPONSIVE WEBISTES

JQUERY COURSE

FLEXBOX COURSE

GRID COURSE

RESPONSIVE COFFEE SHOW WEBSITE

RESPONSIVE CAR DEALERSHIP

COUPONS BELOW!!!!!!

JAVASCRIPT COURSE

BOOTSTRAP COURSE

IN DEPTH HTML AND CSS

RESPONSIVE WEBISTES

JQUERY COURSE

FLEXBOX COURSE

GRID COURSE

RESPONSIVE COFFEE SHOW WEBSITE

RESPONSIVE CAR DEALERSHIP

Products I Use:

Books I Recommend:

Disclosure: This video is not sponsored. Some links above are affiliate links, and l may earn a small commission from any purchases at no additional cost to you. Thank you for supporting my channel!
Рекомендации по теме
Комментарии
Автор

the MOST under rated instructor in youtube AND Udemy .... thank you so much John!!

redwanzia
Автор

Nice John!
Another way is
words="hello everybody how are you";

let toAr = words.split(' ');

console.log(toAr);

let res = toAr.reduce((a, b)=>{
return a.length>b.length?a:b;

});

console.log(res);

codito
Автор

Looking for training videos in our agency and found your channel. Great content. You really got it how to little by little increase students programming confidence and one of the few channels that mix in a great manner challenges, tutorials and project. Keep going!! And thanks for this great content!

bloque.estrategiaseninter
Автор

Thanks for video! Another solution
function longestWord(str) {

let i1 = 0;
let i2 = 0;
let i3 = 0;
str += " ";
for (let i4 = 0; i4 < str.length; i4++) {
if (str.substring(i4, i4 + 1) === " ") {
if (i2 - i1 < i4 - i3) {
i2 = i4;
i1 = i3;
}
i3 = i4 + 1;
}
}
return str.substring(i1, i2);
}

bulatbaltin
Автор

may be just sort the array

e.g
const longestWord = sentence => sentence.split(" ").sort((a, b) => b.length - a.length)[0];

rose
Автор

Bro like, finished a course one day ago, thaught I was good at js for a beginner. Now watching this and feel like my brain expend

sakon
Автор

functional and modern approach -


function longestWord(sentence){
return sentence.split(' ').reduce((acc, str) => str.length > acc.length ?str:acc);
}

sreekumarmenon
Автор

You guys won't believe how i achieved this with the object.entries method
fetchLongestWord(sentence: string){
var countingPoint = 0
var words:string[] = []

(entry, index) => {
if(entry[1] == ' '){
words.push( sentence.slice(countingPoint, index ))
countingPoint = index

}
})

console.log(words)

words.forEach( word =>{
if(word.length > this.longestWord.length){
this.longestWord = word
}
})

}

AntonioRibeiro-qsfy
Автор

Thank you, you explain everything precisely it's almost impossible to not understand : )

deemahalsuwailem
Автор

const longestWord = (str) => str.split(" ").reduce((prev, curr) => curr.length > prev.length ? curr : prev, "");

Lovedeep
Автор

I subscribed because your explanation is very clear, thx bro.

cklam
Автор

What about if word have same length like rightly = thought.then it both as we refresh what about if we blend this to new like if word have same length then by answering must accordingly to alphabetical order please text if possible to make solution

lalit
Автор

Wow!!! nice explanation in the easiest way.

the_awakening_msaha
Автор

Very nice, thank you for your instructions

sellamilobna
Автор

After long time, finally you upload video. Thank U Sir.

saqibkhanz
Автор

Curious if there is multiple words with same length how to output them both?

ThomazMartinez
Автор

John you are awesome man but why 1 algorithm in a 6 minute vid? You sometimes put out a many hours long videos and now this? I love algorithm work and if this was 5 hours of algorithms I would be right here. Love you man you are fantastically unpredictable!

khandoor
Автор

if you have java Script tutorial before the challenge it will be good sir

PaulA-njdk
Автор

Sir, I really appreciate your tutorial. But I have a question.
If there is more than one longestWord what should we do?

jisan-mia
Автор

whats the difference between for of loop and for each method?

serggonta