I got an issue which I feel like there was something I did wrong in my code.
From the instructions, what I understand is that if there is an opening for a platform, book the date for that platform and then stops (essentially returns the array with the platform bookDate updated)
So the first test it runs, Platform A and Platform C has a date booked, thus needing to “book” a date on the available Platform B
Second test that runs, only Platform A has a date booked, so Platform B and C are free, but only need to book one Platform for the mission date and leave Platform C unbooked.
I ran a for … in loop, then did an if statement to find the undefined value, then assigned the missionDate to said index value.
And then I return the array.
When I test my code and it passed all conditions but, it also booked the missionDate for Platform C when it ran the second test.
Here’s my output:
Running test: The bookFreePlatform function should return an array
Index, 0
Platform already booked
Index, 1
Platform is open for booking, null
What is the date to be booked, 2021-12-12
What is the data for of, [{“name”:“Platform A”,“bookDate”:“2021-12-11”},{“name”:“Platform B”,“bookDate”:“2021-12-12”},{“name”:“Platform C”,“bookDate”:“2022-01-12”}]
Running test: The bookFreePlatform function should book one platform
Index, 0
Platform already booked
Index, 1
Platform is open for booking, null
What is the date to be booked, 2021-12-12
What is the data for of, [{“name”:“Platform A”,“bookDate”:“2021-12-11”},{“name”:“Platform B”,“bookDate”:“2021-12-12”},{“name”:“Platform C”}]
Index, 0
Platform already booked
Index, 1
Platform already booked
Index, 2
Platform is open for booking, null
What is the date to be booked, 2021-12-12
What is the data for of, [{“name”:“Platform A”,“bookDate”:“2021-12-11”},{“name”:“Platform B”,“bookDate”:“2022-12-12”},{“name”:“Platform C”,“bookDate”:“2021-12-12”}]