Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.

London class-10 -Junita Lama-JavaScript-1-week 4#221

Open
Junitalama wants to merge 5 commits intoCodeYourFuture:mainfrom
Junitalama:main
Open

London class-10 -Junita Lama-JavaScript-1-week 4#221
Junitalama wants to merge 5 commits intoCodeYourFuture:mainfrom
Junitalama:main

Conversation

@Junitalama
Copy link
Copy Markdown

No description provided.

@Junitalama Junitalama added the review requested I would like a mentor to review my PR label Mar 22, 2023
@jxz12 jxz12 added the reviewed A mentor has reviewed this code label Mar 25, 2023
// return name.length > 7;
//}

let longNameThatStartsWithA = findLongNameThatStartsWithA(names);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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){
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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";
Copy link
Copy Markdown

@jxz12 jxz12 Mar 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like better indentation here

function findSafeOxygenLevel() {}
function findSafeOxygenLevel(oxygenLevels) {
let planets=oxygenLevels.filter(oxygenLevel =>oxygenLevel.includes("%"))
let numberLevels= planets.map(number => parseFloat(number))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you could chain together filter and map with the extra let

*/
function isAccessibleByTransportMode() {}
function isAccessibleByTransportMode(arr, str) {
if(arr.includes(str)){
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

@Junitalama
Copy link
Copy Markdown
Author

@jxz12 Thank you so much jonathan for reviewing. i will make changes as per your feedbacks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

review requested I would like a mentor to review my PR reviewed A mentor has reviewed this code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants