Glasgow-6_JS1-Week-4_Ehdaa-Sakawi#237
Glasgow-6_JS1-Week-4_Ehdaa-Sakawi#237Ehdaa-Munier wants to merge 4 commits intoCodeYourFuture:mainfrom
Conversation
annacollins85
left a comment
There was a problem hiding this comment.
Well done! I have added some comments and some answers to some of the questions. I see you had a little trouble with 6-journey-planner.js. Maybe we can have a look at this in a buddy session. Or I advise you to ask some of your classmates about how they implemented it when you're in class on Saturday.
| function remove() { | ||
| function remove(array, index) { | ||
|
|
||
| return array.slice(0, index).concat(array.slice(index + 1)); |
| function remove() { | ||
| function remove(array, index) { | ||
|
|
||
| return array.slice(0, index).concat(array.slice(index + 1)); |
| numbersWithPercentages = numbers.map(addPercentage); | ||
| return numbersWithPercentages; |
There was a problem hiding this comment.
Here we could simply return the map directly without saving it in a variable and then returning that.
numbers.map(addPercentage);
Good use of map though 👏
| if(value > 19.5 && value < 23.5) | ||
| return result === "%", " . "; | ||
| } | ||
|
|
There was a problem hiding this comment.
Here the function should take an array of percentages as an input (see tests for examples below). So first we need to turn the percentage which is currently a strings into a number. We need to find the first number in the array that is between 19.5 and 23.5. parseFloat will turn a percentage into a number, e.g. parseFloat("25%") === 25
function findSafeOxygenLevel(planetPercentages) {
return planetPercentages.find(function(percentage) {
const number = percentage.parseFloat(percentage)
return (number >= 19.5 && number <= 23.5) // This will return true or false, if it returns true, the `find` array function will return it as the element it finds first
})
}|
|
||
| if (berryArray.every((berry) => berry === "pink")) { | ||
| return "Bush is safe to eat from"; | ||
| } else { | ||
| return "Toxic! Leave bush alone!"; | ||
| } |
| const eligibleAttendance = attended.filter(attendance => attendance[1] >= 8); | ||
| return eligibleAttendance.map(names=> names[0]) |
| function getLanes(streetNames) { | ||
| return streetNames.filter((street) => street.includes("Lane")); | ||
| } |
| let copyOfOriginal = Arr.slice(0, 5); { | ||
| return copyOfOriginal; |
| function sortArray(letters) { | ||
| let copyOfOriginal = [...letters]; | ||
| copyOfOriginal.sort(); | ||
| return copyOfOriginal; |
There was a problem hiding this comment.
This is good. We could also have just directly returned the sorted version like this
| function sortArray(letters) { | |
| let copyOfOriginal = [...letters]; | |
| copyOfOriginal.sort(); | |
| return copyOfOriginal; | |
| function sortArray(letters) { | |
| let copyOfOriginal = [...letters]; | |
| return copyOfOriginal.sort(); | |
| } |
| function tidyUpString(array) { | ||
|
|
||
|
|
||
| return array.map((string) => string.trim().toLowerCase().replace("/", "")); |
No description provided.