-
-
Notifications
You must be signed in to change notification settings - Fork 282
London10-Afsha-Hossain-JS-Core1-Coursework-Week3 #257
base: main
Are you sure you want to change the base?
Conversation
Answered using comments why the outputs in the exercises are undefined
| // fewestNumberOfWords = articleSplitter.length; | ||
|
|
||
| function titleWithFewestWords(allArticleTitles) { | ||
| let shortestHeadline; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could declare 'shortestHeadline' with const keyword instead let
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think shortestHeadline needs to be declared with let here as we are re-assigning a new value to it a few lines later.
SalihaPopal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done!
| For example, "The temperature in London is 10 degrees" | ||
| - Hint: you can call the temperatureService function from your function | ||
| */ | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks perfect 👍
| The home page of the web site has a headline section, which only has space for article titles which are 65 characters or less. | ||
| Implement the function below, which will return a new array containing only article titles which will fit. | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This look good!
For extra practice, can you try re-writing this using the filter array method?
SalihaPopal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!
|
|
||
| // The output in the example below contains undefined because letters is an array with three elements, indexed from 0 to 2. | ||
| // When we try to access the element at index 3 (arr[3]), which is beyond the last index of the letters array, JavaScript returns undefined because there is no value at that index. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice explanation.
| } | ||
| } | ||
|
|
||
| console.log(findFirstJulyBDay(BIRTHDAYS)); // should output "July 11th" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, consice and good.
| */ | ||
| // ["The", "three", "questions", "that", "dominate", "investment"] | ||
| // fewestNumberOfWords = articleSplitter.length; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very good attempt 👍 One small improvement:
- Could you try doing this without using
let fewestNumberOfWords = 1000; - You could either leave it uninitialised and check for
undefinedin your loop.. Or you could maybe initialise to the numberOfWords of the first title in the list.
| // 1. We are getting array of string. We need to find if the string includes numbers. | ||
| // 2. Once we find a number, we will put the string to the new array. | ||
| // 3. We are going to return the new array. New array is string with numbers. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice 👍
| // 2. We need to find the number of Article titles. | ||
| // 3. We divide (total character) by (number of article titles). | ||
| // 4. Round it up | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good!
| // 2. Divide the total price by the number of days i.e. 5 | ||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good variable names 😄
One question: Do you need to re-calculate the average each time through the loop? Maybe it's enough to just calculate the average once at the end?
| In this example it would be: | ||
| (Apple's price on the 5th day) - (Apple's price on the 1st day) = 172.99 - 179.19 = -6.2 | ||
| The price change value should be rounded to 2 decimal places, and should be a number (not a string) | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
One question: Will this code - closingPricesEachcompany[4] - closingPricesEachcompany[0] - still work if we have more than 5 prices in each array? Or less than 5 prices?
Can you think of how to make sure this works for any numbers of prices?
| // } | ||
| // } | ||
| // arrayWithHighestValue.push(highestPrice); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a tough one!
Well done for completing it 👏
|
Great job on this coursework 👏 |
|
Thank you for your consideration and comments. I am going to apple what have you recommended me regarding some exercises. |
We checked if we have an array that is the same length as the number of cities passed in.
No description provided.