Code Monkey home page Code Monkey logo

phase-3-badges-and-schedules's Introduction

Enumerables: Badges and Schedules Lab

Learning Goals

  • Get practice with common enumerable methods

Instructions

In this lab you'll be learning how to iterate through an array and output the results in different ways. Write your code in the conference_badges.rb file and run the test suite using the learn test command.

Create a #badge_maker method

You're hosting a conference and need to print badges for the speakers. Each badge should read: "Hello, my name is _____." Write a badge_maker method that, when provided a person's name, will create and return this message. E.g.:

badge_maker("Arel")
# => "Hello, my name is Arel."

Create a #batch_badge_creator method

Once the list of speakers for your conference has been finalized, you'll want to get the badges printed for all of your speakers.

Write a #batch_badge_creator method that takes an array of names as an argument and returns an array of badge messages.

batch_badge_creator(["Arel", "Carol"])
# => ["Hello, my name is Arel.", "Hello, my name is Carol."]

Create an #assign_rooms method

You just realized that you also need to give each speaker a room assignment. Write a method called #assign_rooms that takes the list of speakers and assigns each speaker to a room. Make sure that each room only has one speaker.

You have rooms 1-7.

Return an array of strings representing room assignments in the form of: "Hello, _____! You'll be assigned to room _____!"

assign_rooms(["Arel", "Carol"])
# => ["Hello, Arel! You'll be assigned to room 1!", "Hello, Carol! You'll be assigned to room 2!"]

Hint: Think about how you will assign a room number to each person. Array items are indexed, meaning that you can access each element by its index number. When you are iterating through an array, you can keep track of the index number of the current iteration using an enumerator method called each_with_index or a closely related method called .with_index.

Hint: Remember that the return value of the #each (or #each_with_index) method is the original array that you are calling it on. What we need to do here is iterate through the array containing the list of speakers, create the room assignment strings for each speaker, and return a new array containing the messages. There is an enumerator method that does just that. Google or use Ruby Docs to find the correct method.

Create a #printer method

Now you have to tell the printer what to print. Create a method called #printer that will output first the results of the #batch_badge_creator method, and then the output of the #assign_rooms method, to the screen.

printer(["Arel", "Carol"])
# Hello, my name is Arel.
# Hello, my name is Carol.
# Hello, Arel! You'll be assigned to room 1!
# Hello, Carol! You'll be assigned to room 2!

Hint: Remember that methods can call other methods. If the return value of #assign_rooms is an array of room assignments, how can you print out each assignment? You'll need to iterate over your array of room assignments in order to puts out each individual assignment.

phase-3-badges-and-schedules's People

Contributors

lizbur10 avatar loganhasson avatar scottcreynolds avatar arelenglish avatar deniznida avatar sarogers avatar ihollander avatar sophiedebenedetto avatar kthffmn avatar msuzoagu avatar maxwellbenton avatar matbalez avatar annjohn avatar ahimmelstoss avatar fs-lms-test-bot avatar bhollan avatar pletcher avatar dunxtand avatar interestinall avatar fislabstest avatar timothylevi avatar aviflombaum avatar ga-be avatar markedwardmurray avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.