London10-Afsha-Hossain-JS1-Week4#236
Conversation
| return singleName.length > 7; | ||
| } | ||
|
|
||
| let longName = names.find(isLongName); |
There was a problem hiding this comment.
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.
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.
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?
|
|
||
| let everyone; // complete this statement | ||
|
|
||
| let everyone = mentors.concat(students); // complete this statement |
There was a problem hiding this comment.
Good use of concat, FYI to combine two arrays it can also be done as below
let everyone = [...mentors, ...students];
|
|
||
| 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.
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.
is singleString accessible here still?
|
|
||
| function getEligibleStudents() {} | ||
| function findName(studentArray) { | ||
| let filterArray = studentArray.filter((element) => {(element[1] >= 8) { |
|
|
||
|
|
||
| function getLanes(roadNames) { | ||
| if (roadNames.includes("Lane")) { |
There was a problem hiding this comment.
As the hint said, indexOf would be useful to help check the partial match in the string.
No description provided.