Giter Site home page Giter Site logo

get_elements's Introduction

Welcome to the get_random_elements 3 ways code challenge!

-------------- THE CHALLENGE

The given environment is built out in lines 4-14 and includes... An array (referenced here as "mystery_array"), containing an unknown of elements A get_element method that will return the next element in mystery_array

The challenge has 3 parts, and the solutions are labeled accordingly within the code. Part 1: Create a method that will return a random element from mystery array. Part 2: Create a method that returns a random element from mystery array WITHOUT creating a new array to do so. Part 3: Create a method that returns a random element from mystery array by only looping once

-------------- INSTRUCTIONS

To run the file in the command line, first fork this repo and navigate to the get_elements directory, which contains get_elements.rb. Open a repl such as irb or pry and require 'get_element.rb'. Note that you will need to provide the full path - for example, on my machine, the path is: /Users/spanuska/Development/code/get_elements/get_elements.rb. Once you have required the file, you can call any of the methods within the repl.

To run the tests, navigate to the get_elements directory and type the following command: 'rspec spec/get_elements_spec.rb'. Next, get excited about all the passing tests!

Note: in order to install rspec on your machine, see the instructions listed here: http://rspec.info/. To install pry, see the instructions listed here: http://pryrepl.org/.

get_elements's People

Contributors

spanuska avatar

Watchers

 avatar

get_elements's Issues

random_number is sometimes set to nil

Most of the time, all tests pass, but sometimes the test that expects get_random_element_without_new_array not to equal nil fails because the variable random_number gets assigned to nil.

screen shot 2015-05-06 at 11 17 21 pm

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.