-
-
Notifications
You must be signed in to change notification settings - Fork 261
Glasgow-6_JS1-Week-4_Ehdaa-Sakawi #237
base: main
Are you sure you want to change the base?
Conversation
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.
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)); |
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.
Nice way of doing it
function remove() { | ||
function remove(array, index) { | ||
|
||
return array.slice(0, index).concat(array.slice(index + 1)); |
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.
Nice way of doing it 👏
numbersWithPercentages = numbers.map(addPercentage); | ||
return numbersWithPercentages; |
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.
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 👏
function findSafeOxygenLevel(result) { | ||
if(value > 19.5 && value < 23.5) | ||
return result === "%", " . "; | ||
} | ||
|
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.
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!"; | ||
} |
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.
Great!
const eligibleAttendance = attended.filter(attendance => attendance[1] >= 8); | ||
return eligibleAttendance.map(names=> names[0]) |
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.
Great 👏
function getLanes(streetNames) { | ||
return streetNames.filter((street) => street.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.
👏
let copyOfOriginal = Arr.slice(0, 5); { | ||
return copyOfOriginal; |
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.
👏
function sortArray(letters) { | ||
let copyOfOriginal = [...letters]; | ||
copyOfOriginal.sort(); | ||
return copyOfOriginal; |
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.
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("/", "")); |
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 method chaining! 👏
No description provided.