London class-10 -Junita Lama-JavaScript-1-week 4#221
London class-10 -Junita Lama-JavaScript-1-week 4#221Junitalama wants to merge 5 commits intoCodeYourFuture:mainfrom
Conversation
| // return name.length > 7; | ||
| //} | ||
|
|
||
| let longNameThatStartsWithA = findLongNameThatStartsWithA(names); |
There was a problem hiding this comment.
For this exercise you should define your own function findLongNameThatStartsWithA and implement your logic there.
| //} | ||
|
|
||
| let longNameThatStartsWithA = findLongNameThatStartsWithA(names); | ||
| let longNameThatStartsWithA = names.find(name => name.length > 7); |
There was a problem hiding this comment.
You have the right idea here but just need to also add logic for starting with A
| // process.exit(1); | ||
|
|
||
| for (let pair of pairsByIndex){ | ||
| if (!pair){ |
There was a problem hiding this comment.
I think here it is better to use pair === null because that will check the type too
|
|
||
| }*/ | ||
|
|
||
| let groupIsOnlyStudents = students.every(name => group.includes(students)? true : false); |
There was a problem hiding this comment.
here you don't need the ternary operator ? because the .includes() function already returns a bool
| */ | ||
|
|
||
| let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; | ||
| arr.forEach(n => { |
There was a problem hiding this comment.
your logic here is good but I think you should take more care to indent your code more neatly
| let firstFive; // complete this statement | ||
| let lastFive; // complete this statement | ||
| let firstFive = everyone.slice(0, 5); // complete this statement | ||
| let lastFive = everyone.slice(2, 7); // complete this statement |
There was a problem hiding this comment.
here you can use negative number indexes with everyone.slice(-5)
| names[1] = names[1].substring(0,7); | ||
| names[2] = names[2].substring(0,4); | ||
| names[3] = names[3].substring(0,4); | ||
| names[4] = names[4].substring(0,5); |
There was a problem hiding this comment.
you could also do e.g. names[4].split(' ')[1] to solve this exercise, but your solution is good
| HINT: You will need to use .substring() twice | ||
| */ | ||
|
|
||
| let statement = "I do not like programming"; |
There was a problem hiding this comment.
you could also use .splice() to nolve this if you turn it into an array first with .split() them .join()
| function findSafeOxygenLevel() {} | ||
| function findSafeOxygenLevel(oxygenLevels) { | ||
| let planets=oxygenLevels.filter(oxygenLevel =>oxygenLevel.includes("%")) | ||
| let numberLevels= planets.map(number => parseFloat(number)) |
| function findSafeOxygenLevel() {} | ||
| function findSafeOxygenLevel(oxygenLevels) { | ||
| let planets=oxygenLevels.filter(oxygenLevel =>oxygenLevel.includes("%")) | ||
| let numberLevels= planets.map(number => parseFloat(number)) |
There was a problem hiding this comment.
here you could chain together the array methods without having to declare variables with let
| function getEligibleStudents() {} | ||
| function getEligibleStudents(students, attendance) { | ||
| let studentName = students.filter(attendance=>attendance[1]>=8) | ||
| return studentName.map(names=>names[0]); |
There was a problem hiding this comment.
here you could chain together filter and map with the extra let
| */ | ||
| function isAccessibleByTransportMode() {} | ||
| function isAccessibleByTransportMode(arr, str) { | ||
| if(arr.includes(str)){ |
There was a problem hiding this comment.
here you could just return the result of .includes() because it is already a boolean
| */ | ||
| function journeyPlanner(locations, transportMode) { | ||
| // Implement the function body | ||
| let accessibleLocations= locations.filter( location=> location.includes(transportMode)) |
There was a problem hiding this comment.
you should use the isAccessibleByTransportMode() function above here, but your solution is also fine
| // Returns true if string contains at least one uppercase letter. | ||
| function containsUppercaseLetter(string) { | ||
| return /[A-Z]/.test(string); | ||
| return string.test(string); |
There was a problem hiding this comment.
this was already correct so no need to change it
|
|
||
| // Returns true if string contains at least one uppercase letter. | ||
| function containsUppercaseLetter(string) { | ||
| return /[A-Z]/.test(string); |
There was a problem hiding this comment.
we have not covered Regex much in class, but you should try to copy the example here. For example, a lower case test would be /[a-z]/.test() and a number would be /[0-9]/.test()
|
@jxz12 Thank you so much jonathan for reviewing. i will make changes as per your feedbacks. |
No description provided.