-
-
Notifications
You must be signed in to change notification settings - Fork 261
London10-Afsha-Hossain-JS1-Week4 #236
base: main
Are you sure you want to change the base?
Conversation
return singleName.length > 7; | ||
} | ||
|
||
let longName = names.find(isLongName); |
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.
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) { |
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.
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); |
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.
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 |
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.
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"); |
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.
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(); |
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.
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) { |
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.
It seems the if
is missing
|
||
|
||
function getLanes(roadNames) { | ||
if (roadNames.includes("Lane")) { |
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.
As the hint said, indexOf would be useful to help check the partial match in the string.
No description provided.