-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: feedback
Are you sure you want to change the base?
Feedback #1
Conversation
Added ToDo & Testing PRs
upload story
function to return a list of objects
Analysing the story
Edite the analyze for the story
JS adds words to html v1
add events for enter
Resposivness
This reverts commit c50cfc8.
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.
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(" "); |
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 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.
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 |
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 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.
if (regex === "v") { | ||
pos = "verb"; | ||
} else if (regex === "n") { | ||
pos = "noun"; | ||
} else if (regex === "o") { | ||
pos = "object"; | ||
} else if (regex === "a") { | ||
pos = "adjective"; | ||
} |
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 and all, but a switch would've made it cleaner.
} else if (regex === "a") { | ||
pos = "adjective"; | ||
} | ||
return { word: word, pos: pos }; |
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.
Love how everything comes down to this at the end.
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 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"); |
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.
You could add the code below into a rest function and call it here to make the code cleaner.
👋! 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:
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”.master
. Click a commit to see specific changes.For more information about this pull request, read “Leaving assignment feedback in GitHub”.
Subscribed: @BKR779 @AhmadHRai @ShadyAlmuraish @AASB7 @Adeeb2022