Q7. Objects (15 Marks)
Complete the functions in q7/objects.js
based on the interface below.
Interface
Function | Description | Parameters | Errors | Success |
---|---|---|---|---|
isSameLength | The function should take in two arrays and returns true if they have the same length, and false otherwise. |
| N/A |
|
zip | Takes in two arrays and combines them together index-wise into a list of lists. |
|
| A list of inner lists, where each inner list pairs the input lists index pair-wise.
|
constructObject | Takes two arrays and returns an object composed of keys from the first array and values from the second. |
|
| If the lists are of the same length:
If a key appears more than once in the first array, the LAST matching value from the second list is used:
|
Marking
When you think your program is working, you can run some simple automated tests:
- tests:
npm run test
Submission
The submission will only collect the q7/objects.js
file. All other files are replaced in automarking.
When you've finished working, submit your answer by running:
submit --question 7
If no submissions have been made for a question, we will take the saved file/s from your working directory.