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

WM4 - Robert Csonka - JS1week3 - #101

Open
RobCso wants to merge 4 commits into
CodeYourFuture:mainfrom
RobCso:main
Open

WM4 - Robert Csonka - JS1week3#101
RobCso wants to merge 4 commits into
CodeYourFuture:mainfrom
RobCso:main

Conversation

@RobCso

@RobCso RobCso commented Aug 19, 2022

Copy link
Copy Markdown

No description provided.

for (let i = 0; i < 5; i++) {
console.log(`${WRITERS[i]} is ${AGES[i]} years old`)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Excellent!

@hayatu4islam hayatu4islam 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.

Creative solutions. Keep it up!

// Example 4
let arr = [1,2,3];
console.log(arr[3]);
console.log(arr[3]); // the index 3 in the array call points to the 4th placed element inside the array, as we count the elements from index 0, index 3 is undefined No newline at end of file

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 is an excellent explanation and good use of comments.

}
i++;
}
return birthday

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A well structured implementation of the function. However, the function will continue to search the presence of July up till the end even after it found the first July. The presence of i++ in line27 made the function not to give wrong output. Because it skips the next July in the array. If you try to input another July birthday after September 28th, you will see that the function will return the last July instead of the first. I suggest you end the while loop immediately you find the occurrence of July. It is also a good practice to put semi-colon after statements such as return in line 29.

let arr = [];
for (const element of cities) {
if (temperatureService(element)) {
arr.push(`The temperature in ${element} is ${temperatureService(element)} degrees`);

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 approach!

}
smallestNumValue = Math.min(...arrLength); //once i had the array of indexes of lenght I went on to find the position of the smallest index in the array in 2 steps, first finding the value of the smallest number
index = arrLength.indexOf(smallestNumValue)//this is the second step of finding the position of the smallest index in an array, this steps finds the position of the smallest number that we identified in the previous step
return allArticleTitles[index]; //finally i return the position of the smallest number of the original array

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 approach is a smart one!

for (const element of allArticleTitles){
if ( /\d/.test(element)) {
array.push(element);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A very good use of regular expression!

}
for (const element of arrNumOfCharacters) {
total = total + element;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The way you declare variables at the beginning is fantastic.

Comment thread 2-mandatory/4-stocks.js
total = total + element;
}
average = total / subArray.length;
total = 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.

I like the creative way of resetting the value of total.

Comment thread 3-extra/3-fibonacci.js
num = 1;
for (let i = 0; i < n - 1; i++) {
arr.push(num);
num = num + arr[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 solution!

cooking.push(books[i]);
}
}
children.sort((a, b) => b.rating - a.rating);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A beautiful way of using arrow function!

Comment thread testFolder/test7.js
for (const subArray of closingPricesForAllStocks) {

highestPriceEach = Math.max(...subArray).toFixed(2);
arrayOfPrices.push(`The highest price of ${stocks[i].toUpperCase()} in the last 5 days was ${highestPriceEach}`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A good solution.

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.

3 participants