Stretch - JavaScript Olympics

Learning Competencies

  1. Create and manipulate objects in JavaScript
  2. Define functions in JavaScript
  3. Use JavaScript built-in methods
  4. Read tests and understand why they're failing

Time Box

ActivityTime
Kata6 hours
Reflect10 minutes

Summary

It is finally time... for the Foundations JavaScript Olympics! You will be completing a pentathlon of challenges to stretch your JavaScript knowledge. You will be going through a variety of tasks. Some you will know how to do already, some will test your research abilities, but all of our events today will require you to read the tests to work out why they are failing and make them pass.

EVENT 0 - The Warm up

Create athlete profiles for you and someone else you know, and then add them to the athleteArray. Each profile should have a name, age, sport, and quote. It would be best if you use object literal notation for this exercise. Run the tests to make sure your properties are correctly defined.

EVENT 1 - Bulk up

Add properties to objects

Use a for loop to add a property called win to every element in athleteArray. win should be a function expression that console logs: "{name} won the {sport} event!"

EVENT 2 - !sdrow ruoy elbmuJ

Reverse a string

Create a function called unjumble that accepts a string as an argument and reverses it.

Use the built-in JavaScript methods for strings and arrays to accomplish this. See the MDN String and Array documentation for all the available methods.

EVENT 3 - 2, 4, 6, 8! Who do we appreciate?

Remove odd numbers from an array

Create a function called removeOdds that accepts an array of numbers. Return an array with only the even numbers.

You can do this manually or use built-in JavaScript Array Methods.

EVENT 4 - "We Built this City"

Build a factory function

Create a function called newAthlete that takes a name, age, sport, and quote and creates a new athlete object from it.

You've made it to the end of the stretch challenge - great effort!