Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops What are Loops?

Splitting sentence to see what word ends with the most common letter.

I am trying to find the letter that the most words in a sentence ends with and all the words that ends with that letter in the following variable. Jen Choi J Meacham Jason Anders Jason Anello Coen van Campenhout

Its my homework and I have tried the split function but it doesn't help and the slice function but it takes to long:.Based on the following variable:

\\\ var sentence = 'Down by the river there is a man that quiver and shiver, but he needs to deliver a packet that he think is a big racket and a packet of of gum.' \\\

1 Answer

Steven Parker
Steven Parker
215,356 Points

You forgot to show your work.

Split should work, but you may have forgotten that you need to remove the punctuation first or ignore it while splitting. Here's an example with a combination of both:

var words = sentence.replace(".","").split(/,? /);

Final answer: MostUsedEnding = "t" — ContributingWords = ["that", "but", "packet", "that", "racket", "packet"]