Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 42 commits into
base: feedback
Choose a base branch
from
Open

Feedback #1

wants to merge 42 commits into from

Conversation

github-classroom[bot]
Copy link

@github-classroom github-classroom bot commented Jan 28, 2023

👋! GitHub Classroom created this pull request as a place for your teacher to leave feedback on your work. It will update automatically. Don’t close or merge this pull request, unless you’re instructed to do so by your teacher.
In this pull request, your teacher can leave comments and feedback on your code. Click the Subscribe button to be notified if that happens.
Click the Files changed or Commits tab to see all of the changes pushed to master since the assignment started. Your teacher can see this too.

Notes for teachers

Use this PR to leave feedback. Here are some tips:

  • Click the Files changed tab to see all of the changes pushed to master since the assignment started. To leave comments on specific lines of code, put your cursor over a line of code and click the blue + (plus sign). To learn more about comments, read “Commenting on a pull request”.
  • Click the Commits tab to see the commits pushed to master. Click a commit to see specific changes.
  • If you turned on autograding, then click the Checks tab to see the results.
  • This page is an overview. It shows commits, line comments, and general comments. You can leave a general comment below.
    For more information about this pull request, read “Leaving assignment feedback in GitHub”.

Subscribed: @BKR779 @AhmadHRai @ShadyAlmuraish @AASB7 @Adeeb2022

@tech-chieftain tech-chieftain self-assigned this Feb 9, 2023
Copy link

@tech-chieftain tech-chieftain left a comment

Choose a reason for hiding this comment

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

In addition to what I mentioned, I also want to commend you on adding comments to this code. It was a really good thing.

Great job over all with everything you've done here.

function parseStory(rawStory) {
// Your code here.
return {}; // This line is currently wrong :)
let arr = rawStory.split(" ");

Choose a reason for hiding this comment

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

Suggested change
let arr = rawStory.split(" ");
const arr = rawStory.split(" ");

Refrain from using let and use const instead. Unless you want to change the value of this variable later on.

Comment on lines +32 to +53
let newArr = arr.map((ele) => {
if (ele.includes("[")) {
// if it contains [
let pos;
let index = ele.indexOf("[");
let word = ele.slice(0, index); // take the word
let regex = ele.match(/\[(.*?)\]/)[1]; //take the character inside the square //Dot . =>match any character except newlines Quantifier * => Match 0 or more of the preceding token. Lazy ? =>Makes the preceding quantifier lazy, causing it to match as few characters as possible.
if (regex === "v") {
pos = "verb";
} else if (regex === "n") {
pos = "noun";
} else if (regex === "o") {
pos = "object";
} else if (regex === "a") {
pos = "adjective";
}
return { word: word, pos: pos };
} else {
return { word: ele };
}
});
return newArr; // new array

Choose a reason for hiding this comment

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

Suggested change
let newArr = arr.map((ele) => {
if (ele.includes("[")) {
// if it contains [
let pos;
let index = ele.indexOf("[");
let word = ele.slice(0, index); // take the word
let regex = ele.match(/\[(.*?)\]/)[1]; //take the character inside the square //Dot . =>match any character except newlines Quantifier * => Match 0 or more of the preceding token. Lazy ? =>Makes the preceding quantifier lazy, causing it to match as few characters as possible.
if (regex === "v") {
pos = "verb";
} else if (regex === "n") {
pos = "noun";
} else if (regex === "o") {
pos = "object";
} else if (regex === "a") {
pos = "adjective";
}
return { word: word, pos: pos };
} else {
return { word: ele };
}
});
return newArr; // new array
return arr.map((ele) => {
if (ele.includes("[")) {
// if it contains [
let pos;
let index = ele.indexOf("[");
let word = ele.slice(0, index); // take the word
let regex = ele.match(/\[(.*?)\]/)[1]; //take the character inside the square //Dot . =>match any character except newlines Quantifier * => Match 0 or more of the preceding token. Lazy ? =>Makes the preceding quantifier lazy, causing it to match as few characters as possible.
if (regex === "v") {
pos = "verb";
} else if (regex === "n") {
pos = "noun";
} else if (regex === "o") {
pos = "object";
} else if (regex === "a") {
pos = "adjective";
}
return { word: word, pos: pos };
} else {
return { word: ele };
}
});

This is a more concise way of writing this block.

Comment on lines +39 to +47
if (regex === "v") {
pos = "verb";
} else if (regex === "n") {
pos = "noun";
} else if (regex === "o") {
pos = "object";
} else if (regex === "a") {
pos = "adjective";
}

Choose a reason for hiding this comment

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

This is good and all, but a switch would've made it cleaner.

} else if (regex === "a") {
pos = "adjective";
}
return { word: word, pos: pos };

Choose a reason for hiding this comment

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

Love how everything comes down to this at the end.

Copy link

@hiba-machfej hiba-machfej left a comment

Choose a reason for hiding this comment

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

Great work team! Only minor feedbacks about clean code and organisation. Instead of having all the fonts uploaded to your project you can keep only the ones you need as it will all be loaded to your website. You can also check google fonts.

.then(parseStory)
.then((processedStory) => {
buildStory(processedStory);
const reset = document.getElementById("reset");

Choose a reason for hiding this comment

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

You could add the code below into a rest function and call it here to make the code cleaner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants