Git Product home page Git Product logo

dice-roll-ruby-dumbo-web-091718's Introduction

Dice Roll

Objectives

  1. Write code within a method.
  2. Get more practice returning values.
  3. Explore number ranges.

Ruby Ranges

In Ruby, a "range" is a set of values with a beginning and an end. A range can contain strings or integers.

A range of strings: ("a", "b", "c", "d")

A range of integers: (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

A range can be constructed using this notation: (100..200)

Or this notation: (100...200)

Using a .. ("double-dot") includes the second number (200) in the range, while using a ... ("triple-dot") excludes it.

Ranges can be helpful when you are generating arrays which we will be learning more about soon.

##Instructions

Inside the dice_roll.rb file, define a method roll that returns a random number between one (1) and six (6).

Hint: Try googling "how to generate a random number in ruby".

##Bonus

There are different ways to complete this lab. First, try to solve it by using ranges. Then for some extra fun, try to solve this lab using an array.

Hint: Think about how you can grab a random element out of an array.

Resources

View Dice Roll on Learn.co and start learning to code for free.

dice-roll-ruby-dumbo-web-091718's People

Contributors

ahimmelstoss avatar annjohn avatar aviflombaum avatar changamanda avatar damianb1451 avatar fislabstest avatar fs-lms-test-bot avatar irmiller22 avatar joshuabamboo avatar kthffmn avatar markedwardmurray avatar sarogers avatar sophiedebenedetto avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.