London | 26-ITP-May | Jorvan White | Sprint 2 | Coursework - #1418
London | 26-ITP-May | Jorvan White | Sprint 2 | Coursework #1418JorvanW wants to merge 26 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| function tally(array) { //(array) is the input to the function | ||
|
|
||
| if (!Array.isArray(array)){ //checking if array is actually an array | ||
| throw new Error("Input must be an array"); | ||
| } | ||
|
|
||
| if (array.length === 0){ //if array is empty return a empty array | ||
| return [] | ||
| } | ||
|
|
||
|
|
||
| const result = {} //creates result as an empty object which will store the counts | ||
|
|
||
|
|
||
| for (const item of array){ //'for' loops through every item in the array | ||
| if (result[item]){ // checks if the item is already in the result{} | ||
| result[item]++} // If it is then '++' tells it to add 1 to the value | ||
|
|
||
| else { | ||
| result[item] = 1; // else is saying that if it doesn't exist then we give it a value of 1 |
There was a problem hiding this comment.
I generally appreciate the comments adding clarity for future ref and readers, but it's not needed and maybe makes the committed code messy. This solution is fairly easy to interpret without it and we want clean commits as much as possible
There was a problem hiding this comment.
this did not remove comments - please remove unnecesary comments
Poonam-raj
left a comment
There was a problem hiding this comment.
Some great work writing tests and implementing solutions - a few comments worth addressing, especially in the interpret section where testing is particularly lacking
…object as required
…test cases for invert
Poonam-raj
left a comment
There was a problem hiding this comment.
Small remaining bits here - good work making corrections. I did leave some comments about test cases which you did not address in the implement section (particularly lookup), can you look at that and my other remainign comments - thanks!
|
Hi @JorvanW try again- github should be resolved |
|
updated test cases for invert and lookup |

Self checklist
Changelist
Created Pull Request from Sprint 2 Coursework and updated for Pull Request