Conversation
| Article.all.push(new Article(ele)); | ||
| }); | ||
| */ | ||
| rows.map(ele => Article.all.push(new Article(ele))); |
There was a problem hiding this comment.
Remember .map returns a new array, so instead of doing Article.all.push() you could just assign Article.all = rows.map(.....)
| // DONE: Chain together a `map` and a `reduce` call to get a rough count of all words in all articles. | ||
|
|
||
| Article.numWordsAll = () => { | ||
| return Article.all.map(a => a.body.length).reduce((acc, cur) => acc + cur); |
There was a problem hiding this comment.
What is a.body.length going to return you? Here a represents each article. And a.body is the body of the article and a.body.length is going to return you the length of the body. But you actually want the length of the article by words. SO you'r missing a step -----> split!
|
|
||
| // DONE: Chain together a `map` and a `reduce` call to produce an array of unique author names. You will | ||
| // probably need to use the optional accumulator argument in your reduce call. | ||
| Article.allAuthors = () => Article.all.map(a => a.author).reduce((acc, cur) => acc.includes(cur) ? acc : acc.concat([cur]), []); |
There was a problem hiding this comment.
Note: Instead of using acc.concat, you could just use push like so acc.push(cur)
| author: author, | ||
| articleCount: Article.all.filter(a => a.author === author).length, | ||
| wordCount: Article.all.filter(a => a.author === author) | ||
| .map(a => a.body.length) |
|
Missing |
|
package.json should not be missing. You can find it here on our repo https://github.com/sharmarkei/10-functional_programming/blob/nathan-sharmarke/starter-code/package.json |
|
Hmm weird, for some reason I didn't see it. My bad! |
|
|
||
| Article.numWordsAll = () => { | ||
| return Article.all.map(a => a.body.length).reduce((acc, cur) => acc + cur); | ||
| return Article.all.map(a => a.body.split().length).reduce((acc, cur) => acc + cur); |
|
Nice :) 👍 |
|
It was working before even without installing fs. IIRC, fs is a default node package, right? |
|
You're absolutely right. We don't need to include |
Single-line Summary
Today, Sharmarke and Nathan paired together. It took about 2:20
Reflect and summarize on your process for each
TODOitem :Checklist (before submitting, fill in each set of square brackets with an 'x')
TODO:process above.