Question
Here is the javascript assignment. Im having a hard time figuring this one out. Part 1: Create More Objects Using the two provided object literals
Here is the javascript assignment. Im having a hard time figuring this one out.
Part 1: Create More Objects
Using the two provided object literals as examples, create new object literals for the three remaining animals (Name, Species, Mass (kg), Age (years)).
Animal = (Brad, Chimpanzee, 11, 6)
Animal = (Leroy, Beagle, 14, 5)
Animal = (Almina, Tardigrade, 0.0000000001, 1)
Add a New Property to the Objects
For each animal, add a property called astronautID. Each astronautID should be assigned a number between 1 and 10 (including 10). However, no crew members should have the same ID.
Add a New Method to the Objects
Add a move method to each animal object. The move method will select a random number of steps from 0 to 10 for the animal to take. The number can be 0 as well as 10.
Store the Objects
Create a crew array to store all of the animal objects.
Part 2: Crew Reports
Upper management at the space base wants us to report all of the relevant information about the animal astronauts.
Define a crewReports function to accomplish this. When passed one of the animal objects, the function returns a template literal with the following string:
'____ is a ____. They are ____ years old and ____ kilograms. Their ID is ____.'
Fill in the blanks with the name, species, age, mass, and ID for the selected animal.
Part 3: Crew Fitness
Before these animal astronauts can get ready for launch, they need to take a physical fitness test. Define a fitnessTest function that takes an array as a parameter.
Within the function, race the five animals together by using the move method. An animal is done with the race when they reach 20 steps or greater. Create a new array to store how many turns it takes each animal to complete the race. Store the data as a string: '____ took ____ turns to take 20 steps.' Fill in the blanks with the animal's name and race result.
Return the array from the function, then print the results to the console (one animal per line).
HINT: There are a lot of different ways to approach this problem. One way that works well is to see how many iterations of the move method it will take for each animal to reach 20 steps.
Here is what ive done so far. Need some help finishing up the code correctly
// Code your crewReports function here:
function crewReports(name, species, age, mass) { for (let i = 0; i < crewArray.length; i++) return '${name[i]} is a ${species[i]}. They are ${age[i]} years old and ${mass[i]} kilograms. Thier ID is ${astronautID[i]}'; } // Code your fitnessTest function here: function fitnessTest(){ } // Code your objects and crew array here: let superChimpOne = { astronautID: 1, name: "Chad", species: "Chimpanzee", mass: 9, age: 6 }; let superChimpTwo = { astronautID: 2, name: "Brad", species: "Chimpanzee", mass: 11, age: 6 }; let salamander = { astronautID: 3, name: "Lacey", species: "Axolotl Salamander", mass: 0.1, age: 5 }; let dog = { astronautID: 4, name: "Leroy", species: "Beagle", mass: 14, age: 5, }; let waterBear = { atronautID: 5, name: "Almina", species: "Tardigrade", mass: 0.0000000001, age: 1, }; let crewArray = [superChimpOne, superChimpTwo, salamander, dog, waterBear]; //
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started