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

London10-Afsha-Hossain-JS1-Week4 #236

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

Afsha10
Copy link

@Afsha10 Afsha10 commented Apr 5, 2023

No description provided.

@Afsha10 Afsha10 added the review requested I would like a mentor to review my PR label Apr 11, 2023
return singleName.length > 7;
}

let longName = names.find(isLongName);

Choose a reason for hiding this comment

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

Good use of find function. FYI it is also possible to write line 23-27 into one statement. The benefit is that you can save the effort on thinking a function name isLongName. It is a personal coding style, not a rule to follow though.

let longName = names.find((name) => singleName.length > 7);


let nameStartingWithA = names.find(isStartingWithA);

function findLongNameThatStartsWithA(names) {

Choose a reason for hiding this comment

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

The names parameter is being used inside the function, do you think it can be removed?

To write the code simpler, on line 40 we can do the comparison directly as there is just one line of code.

let longNameThatStartsWithA = nameStartingWithA && longName;

let groupIsOnlyStudents = group.every(isOnlyStudent); // complete this statement

function isOnlyStudent(list) {
return list.includes(students);

Choose a reason for hiding this comment

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

Good use of every. What is the value of list? is it the element of group like "Austine", "Dany"... ?
on line 11 if we want to check if the name from the group is included in students array, it should be like students.includes right?

@@ -7,7 +7,9 @@
let mentors = ["Daniel", "Irina", "Rares"];
let students = ["Rukmini", "Abdul", "Austine", "Swathi"];

let everyone; // complete this statement

let everyone = mentors.concat(students); // complete this statement

Choose a reason for hiding this comment

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

Good use of concat, FYI to combine two arrays it can also be done as below

let everyone = [...mentors, ...students];

@@ -13,7 +13,8 @@
let story =
"I like dogs. One day I went to the park and I saw 10 dogs. It was a great day.";

let result = story.replace("", "");
let result =
story.replace("dogs", "cats").replace("day", "night").replace("10", "100000").replace("dogs", "cats").replace("great", "brilliant").replace("day", "night");

Choose a reason for hiding this comment

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

Good use of replace, FYI there is a way to replace all the occurrence with one replace function, in this case we want to replace dogs into cats, it can be done by regular expression with the global flag g. If you are interested you can look it up.

story.replace(/dogs/g, 'cats')

for (const singleString of arrayOfStrings) {
console.log(singleString.trim());
}
return singleString.trim().replace("/","").toLowerCase();

Choose a reason for hiding this comment

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

is singleString accessible here still?

@@ -7,7 +7,14 @@
- Returns an array containing only the names of the who have attended AT LEAST 8 classes
*/

function getEligibleStudents() {}
function findName(studentArray) {
let filterArray = studentArray.filter((element) => {(element[1] >= 8) {

Choose a reason for hiding this comment

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

It seems the if is missing



function getLanes(roadNames) {
if (roadNames.includes("Lane")) {

Choose a reason for hiding this comment

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

As the hint said, indexOf would be useful to help check the partial match in the string.

@kitko112 kitko112 added the reviewed A mentor has reviewed this code label Apr 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
review requested I would like a mentor to review my PR reviewed A mentor has reviewed this code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants