Display more details in splice example#55
Conversation
Naming of variables was confusing + there was no hint in the qunit output. For more details see: liammclennan#47
| var weekend = daysOfWeek; | ||
|
|
||
| deepEqual(workingWeek, ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'], 'what is the value of workingWeek?'); | ||
| deepEqual(weekend, ['Saturday', 'Sunday'], 'what is the value of daysOfWeek?'); |
There was a problem hiding this comment.
What is intended here? This will fail and there is no placeholder to fix it.
There was a problem hiding this comment.
Damn. I removed my previous comment here by mistake.
The thing is - I changed the variable names to indicate which days go where. If you pass 0 and 5 as splice call args then it will pass the test. I checked it.
There was a problem hiding this comment.
I still don't see how to make it pass. The test on line 25 fails because weekend is ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']. There has to be somewhere to make it pass.
There was a problem hiding this comment.
There is because splice modifies the source table - let me explain in more details.
In this case: var workingWeek = daysOfWeek.splice(0, 5); leaves ['Saturday', 'Sunday'] in daysOfWeek and returns days from 'Monday' to 'Friday' as a new array which we then assign to a variable named workingWeek. Since that name is misleading now I reassign reference kept in there to a variable named weekend. Just to make the deepEqual calls more welcoming ;)
As a result: workingWeek has 5 elements; weekend has 2; end of story. Have you tried it?
There was a problem hiding this comment.
I see that test description is still misleading - 'what is the value of daysOfWeek?' should be '... of weekend'.
|
Thanks. |
Naming of variables was confusing + there was no hint in the qunit output.
For more details see:
#47