WDI Fundamentals

WDI Fundamentals Unit 11


Your Turn Your Turn

Now things are starting to heat up! Let's take a short break from our contact book to practice iterating over arrays.

Instructions

1) Write the code to perform the actions listed below using JS Bin editor. If you don't see the JS Bin, 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.

JS Bin on jsbin.com

Let's get started!

Part 1

1) Create an array, cups, containing the numbers 1 - 10. 2) Create an empty array, ounces. 3) Write a function, convertToOunces. It should iterate through the cups array, convert each item from cups to ounces, and then add that item to the ounces array. Return the value of ounces after looping through the items and before the function ends.

Part 2

1) Create an array, scores, containing the numbers 83, 40, 55, 72, 59, 88, and 99. 2) Write a function, passOrFail. It should loop through the scores array and replace the current item with 'pass' if the score is greater than or equal to 60 and 'fail' if the score is less than 60. Return the scores array.

Feeling comfortable with these exercises? Take a look at the last lesson!

Stuck? Check out the solutions to see what you can do.


Ready for the last lesson? Here it comes!