Stretch — JavaScript Olympics

The Big Idea

The JavaScript Olympics is a stretch challenge: five events that test your ability to create objects, write functions, use built-in methods, and read tests to understand what is expected. Some of this you already know how to do. Some will require research.

Your Roadmap

SectionTimeRequired?
Setup5 min◎ Optional
Event 0 — The Warm-up30 min◎ Optional
Event 1 — Bulk Up1 hr◎ Optional
Event 2 — Jumble Your Words1 hr◎ Optional
Event 3 — Remove the Odds1 hr◎ Optional
Event 4 — Factory Function1 hr◎ Optional

Setup

The JavaScript Olympics lives in the same repo as the other kata. Run the tests:

npm test stretch-js-olympics

Event 0 — The Warm-up

Create athlete profiles for yourself and someone else you know. Add both to the athleteArray.

Each profile needs: name, age, sport, and quote. Use object literal notation.

Run the tests to confirm your properties are defined correctly.


Event 1 — Bulk Up

Add properties to objects

Use a for loop to add a win property to every element in athleteArray.

win should be a function expression that console.logs: "{name} won the {sport} event!"


Event 2 — Jumble Your Words

Reverse a string

Create a function called unjumble that takes a string and returns it reversed.

Use the built-in methods available for strings and arrays.


Event 3 — Remove the Odds

Remove odd numbers from an array

Create a function called removeOdds that takes an array of numbers and returns only the even ones.

You can do this manually or use a built-in Array method.


Event 4 — Factory Function

Build a factory function

Create a function called newAthlete that takes name, age, sport, and quote as parameters and returns a new athlete object.

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