Grammar Checker additional improvements help for beginner JavaScript course

In the grammar checker project in the beginner javasctipt course, there is some additional improvements you can do for extra practice.
one says " Changing the imperial units of measurement (feet and miles) to metric units (meters and kilometers). "
does anyone know how to get the numbers out of an array of strings?

this is what I have so far:

let story = ‘56 Last weekend, I took literally the most beautifull bike ride of my life. The route is called “The 9W to Nyack” and it stretches all the way from Riverside Park in Manhattan to South Nyack, New Jersey. It's really an adventure from beginning to end! It is a 48 mile loop and it literally took me an entire day. I stopped at Riverbank State Park to take some artsy photos. It was a short stop, though, because I had a freaking long way to go. After a quick photo op at the very popular Little Red Lighthouse I began my trek across the George Washington Bridge into New Jersey. The GW is a breathtaking 4,760 feet long! I was already very tired by the time I got to the other side. An hour later, I reached Greenbrook Nature Sanctuary, an extremely beautifull park along the coast of the Hudson. Something that was very surprising to me was that near the end of the route you literally cross back into New York! At this point, you are very close to the very end.’;

let storyWords = story.split(’ ');
let unnecessaryWord = ‘literally’;
let misspelledWord = ‘beautifull’;
let badWord = ‘freaking’;


let count = 0;
storyWords.forEach(word => {
return count++


storyWords = storyWords.filter(word => {
return word !==unnecessaryWord;

storyWords = => {
return word === misspelledWord ? ‘beautiful’ : word;

let badWordIndex = storyWords.findIndex((word) => {
return word === badWord

storyWords[78] = ‘really’;

let lengthCheck = storyWords.every((word) => {
return word >= 10

let toLongIndex = storyWords.filter((word) =>{
return word.length > 10

let changeWord =storyWords.findIndex((word) => {
return word === ‘breathtaking’

storyWords[111] = ‘glorious’

for (let i = 0; i < storyWords.length; i++){
if (storyWords[i] === ‘very’){
} else {

for (let i = 0; i < storyWords.length; i++){
if (storyWords[i] === ‘GW’){
storyWords.splice(i,1, ‘George Washington’);
} else {

for(let i = 0; i<storyWords.length; i++){
if (typeof storyWords[i] === ‘number’ && storyWords[i+1] === ‘feet’){
storyWords[i] /= 3.28;
storyWords[i+1] = ‘meters’;
} else if (typeof storyWords[i] === ‘number’ && storyWords[i+1] === ‘miles’){
storyWords[i] *= 1.609;
soryWords[i+1] = ‘kilometers’;
} else {


console.log(storyWords.join(’ '));

but the issue was pulling the numbers out of an array of strings.
Ive found ways to do it, but none that seem to belong in a beginner course.
anyone have input on how they did or would do it?
Or input on the way the way you would think the lesson would have you do it with the knowledge that one would posses in the beginner course?

Please post a link to the project, and also a copy of the storyWords array for us to test with.

The 48 mile is simple enough, but the 4,760 feet is a little trickier.

Consider the following:

 > isNaN('4,760')
<- true
 > parseInt('4,760', 10)
<- NaN
> +'4,760'
<- NaN
 > Number('4,760')
<- NaN

In other words, JavaScript does not recognize a number with a comma in it.

link :

storyWords = [
‘56’, ‘Last’, ‘weekend,’, ‘I’, ‘took’,
‘the’, ‘most’, ‘beautiful’, ‘bike’, ‘ride’,
‘of’, ‘my’, ‘life.’, ‘The’, ‘route’,
‘is’, ‘called’, ‘"The’, ‘9W’, ‘to’,
‘Nyack"’, ‘and’, ‘it’, ‘stretches’, ‘all’,
‘the’, ‘way’, ‘from’, ‘Riverside’, ‘Park’,
‘in’, ‘Manhattan’, ‘to’, ‘South’, ‘Nyack,’,
‘New’, ‘Jersey.’, “It’s”, ‘really’, ‘an’,
‘adventure’, ‘from’, ‘beginning’, ‘to’, ‘end!’,
‘It’, ‘is’, ‘a’, 77.232, ‘kilometers’,
‘loop’, ‘and’, ‘it’, ‘took’, ‘me’,
‘an’, ‘entire’, ‘day.’, ‘I’, ‘stopped’,
‘at’, ‘Riverbank’, ‘State’, ‘Park’, ‘to’,
‘take’, ‘some’, ‘artsy’, ‘photos.’, ‘It’,
‘was’, ‘a’, ‘short’, ‘stop,’, ‘though,’,
‘because’, ‘I’, ‘had’, ‘really’, ‘freaking’,
‘long’, ‘way’, ‘to’, ‘go.’, ‘After’,
‘a’, ‘quick’, ‘photo’, ‘op’, ‘at’,
‘the’, ‘popular’, ‘Little’, ‘Red’, ‘Lighthouse’,
‘I’, ‘began’, ‘my’, ‘trek’, ‘across’,
… 75 more items

And thank you for the help. I was stuck on the first conversion and never made it to the miles to km conversion. I got the miles to km just fine now. not once did I think the comma was going to be my downfall. Had a friend of mine who has been coding for almost 2 years help me look into this and could not find any simple answers. Odd this would be in the course for beginners, however, it is at the end hint section for additional practice and not part of the necessary steps, still odd though.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.