WDI Fundamentals Unit 11
Time to give it a whirl! In this exercise you'll practice setting up and updating a
contacts array. Later in this unit we'll be adding some complexity and creating a more robust contact book that allows us to store more detailed information, enter new contacts, list contacts, and search contacts by first or last name.
1) Write the code to perform the actions listed below using JS Bin editor. If you don't see the JS Bin below, please refresh the page. 2) Click "Run" to run the code in the "Console" panel. 3) Call each function from the "Console" panel. Try using different parameters to make sure they're working properly.
contactsarray. This array should contain the names "Matt Smith," "Sam Davis," and "Ashley Jones."
findContactfunction, which accepts one parameter,
index. It should return the contact at that index.
addContactfunction, which accepts one parameter,
name. It should add that name to the end of the
contactsarray and return the
updateLastContactfunction, which accepts one parameter,
newName. It should update the last contact in the
contactsarray with the new name and return the
Once you're satisfied, feel free to move on to the next lesson. Be sure to save your JS Bin session and keep your link, as you'll be using it again for another exercise in this unit.
Stuck? Check out the solutions to see what you can do.