I completed the exercises, but the instructions for adding the
astronautID property and printing the crew fitness results confuse me.
220.127.116.11. Add a New Property
For each animal, add a property called
astronautIDshould be assigned a number between 1 and 10 (including 10). However, no crew members should have the same ID.
Initially, I manually assigned each object an ID (ex. 2, 4, 6, 8, 10). But, the instructions stated that IDs should include 10 and not repeat. I created functions to generate a random number between 1 and 10 for each animal. I included conditionals to prevent duplicate IDs from being created. One of my solutions generated a TypeError at the end of the iteration. The other duplicated some of the IDs.
I’ve studied different approaches to creating unique IDs. I tried to apply some concepts to my code, but nothing has worked so far. Are we generating random IDs or manually assigning IDs for objects?
Return the array from the function, then print the results to the console (one animal per line).
With the crew report, I’ve been able to implement the move method. I am unsure if I’m printing it correctly. Right now, it prints the string with all the correct information for each iteration and returns the array.
Is it printed in the wrong order because it’s printing the moves first and the array second?