Marian Horoiu - #1
Conversation
alexonaci
left a comment
There was a problem hiding this comment.
Very good, I liked that you used ES6 features, a lot of array methods and the code is clean
|
|
||
| var strArr = ["13", "2", "34", "14", "5", "86", "3.46"]; | ||
|
|
||
| const typeCastAndAdd = arr => arr.map(item => (Number(item) + 2).toString()); |
There was a problem hiding this comment.
For this situation is okay to use Number(item). Don't forget that there is also the parseInt() method which can save you in some cases:
https://stackoverflow.com/questions/4564158/what-is-the-difference-between-parseintstring-and-numberstring-in-javascript#answer-4564199
There was a problem hiding this comment.
In this situation, if I use parseInt(), the last item "3.46" will be converted to an integer and will return an "5".
Maybe it would be good to use parseFloat() instead of parseInt() or Number() ??
There was a problem hiding this comment.
yes, sorry I missed the float. parseFloat() would be better ;)
| b = 8; | ||
|
|
||
| (function() { | ||
| [a, b] = [b, a]; |
There was a problem hiding this comment.
very nice that you used destructuring assignment
| const key = ["subject", "time", "teacher"]; | ||
|
|
||
| const objClasses = classes.map(item => | ||
| item.reduce((acc, val, ind) => ((acc[key[ind]] = val), acc), {}) |
There was a problem hiding this comment.
can you maybe make this a little more readable by naming the variables more descriptive?
but very good use of reduce, I like it
There was a problem hiding this comment.
I did some updates to variable names and inserted some console.log's to highlight the current iteration elements and values, both in .map() and .reduce() methods.
Resolved all exercises. Each exercise has it's own commit.