Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.

ZA2-Kwanda Silekwa-JavaScript-Core-1-Coursework-Week-3 - #67

Open
kwanda9700 wants to merge 10 commits into
CodeYourFuture:mainfrom
kwanda9700:main
Open

ZA2-Kwanda Silekwa-JavaScript-Core-1-Coursework-Week-3#67
kwanda9700 wants to merge 10 commits into
CodeYourFuture:mainfrom
kwanda9700:main

Conversation

@kwanda9700

Copy link
Copy Markdown

No description provided.

@dschouw-CYF dschouw-CYF left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work Kwanda! Keep it up!


function evenNumbers(n) {
// TODO
let i = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function evenNumbers(10) should log [0,2,4,6,8] in its current form.
Looking at the expected output of invoking it (line 20) for argument 3, it should log 0,2,4.
It seems like the function evenNumbers should log the first n even numbers, where n is the argument to the function.


function findFirstJulyBDay(birthdays) {
// TODO
arrayLength = birthdays.length;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done!

// i++;
// }

for (i; i < 26; i++) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit of code raises a ReferenceError.
What do you think is missing from the for statement?

"Tottenham Court Road",
];

for (let i = 0; i < tubeStations.length; i++) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!.
This works perfectly fine, but the requirement is to use a for-of loop.
See MDN and W3Schools for more information.

// TODO Use a for-of loop to capitalise and output each letter in the string seperately.
let str = "codeyourfuture";

for (let i = 0; i < str.length; i++) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works perfectly fine!
Using the same comment above though, attempt this with the for-of loop

// TODO
// TODO
let temperatureReport = [];
cities.forEach((cityName) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of .forEach!


function getRandomNumberGreaterThan50() {
// TODO - implement using a do-while loop
// TODO - implement using a do-while loop

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done!

function potentialHeadlines(allArticleTitles) {
// TODO
// TODO
let potentialArticles = allArticleTitles.filter(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 Good use of .filter()

// TODO
for (let shortestTitle of allArticleTitles) {
let fewestWordTitle = shortestTitle.split(" ");
if (fewestWordTitle.length <= 7) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the number 7 used to determine the fewest words?
This might be a case of magic numbers and should be avoided when coding.
If a new title, with a even shorter title is introduced, will this function still work?

function headlinesWithNumbers(allArticleTitles) {
// TODO
// TODO
let titleWithNumArr = [];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regex 😳 . Nice Work!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants