Coder Social home page Coder Social logo

intro-se-ruby-methods-practice's Introduction

Ruby Methods Practice 1!

Welcome back! We're going to jump in to practicing building methods in Ruby. Remember that methods are chunks of code that we name and can call at any time.

The synax for a method in Ruby is:

def method_name(input)
  # code using the input variable
end

Challenges

Create a new Ruby file called 'methods-practice.rb' with the touch command in your command line. Open up the file and code the following functions. Make sure to test them out by calling the function and then running ruby methods-practice.rb from the command line!

    1. Build a method timesByOneThousand that takes an integer and multiplies it by 1000. (We started this one for you)
def timesByOneThousand(number)
      #code here
    end
    1. Build a method howOldIWillBeIn2030 that takes in your age (as an integer) and tells you how old you will be in the year 2030. (16 -> 30)
    1. Build a method makeExcited that takes a string, makes it all uppercase and adds three exclamation points. ("hello" -> "HELLO!!!")
    1. Build a method called happyBackwards that takes in a string, reverses it, and then adds on a smiley face character at the end. ("cool" -> "looc :)")
    1. Build a method called isEven that returns a boolean (true or false) depending on whether or not the number is divisible by 2. (3 -> false, 4 -> true)
    1. Build a method called gradeCalculator that takes in a number (0 to 100) and returns the letter grade that corresponds to it. (95 -> "A", 85 -> "B")

intro-se-ruby-methods-practice's People

Contributors

dfenjves avatar kristynrb avatar twant avatar

Watchers

 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.