Git Product home page Git Product logo

pfwtfp-practice-with-array-integers-lab-dc-web-mod1-repeat's Introduction

Practice with Array Integers

Introduction

In this lab, we will be practicing some of the common ways to access and manipulate information from an array.

Learning Goals

  • Access values in arrays
  • Perform operations on arrays

Perform Operations on Arrays

This lab focuses on arrays of integers but involves a few concepts from algebra. Just as a brief refresher on some of these concepts:

To square a number, multiple the number by itself. In mathematical notation, this is written using a exponent: 52 == 5 x 5 == 25

To cube a number, multiple a number by itself two times. 53 == 5 x 5 x 5 == 125

To sum a set of numbers, add them together

To average a set of numbers, get their sum and divide by how many numbers are in the set

Your task is to write a set of methods that take in an any array of integers, perform a math operation on each integer and return a new array. In lib/array_practice.rb, an example array is provided:

array_of_integers = *0..50
# => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,  ...  47, 48, 49]

This method of array creation uses a 'splat' operator on a range. This is a shorthand method for creating and assigning an array of integers

Feel free to modify this array or use your own array to test and write these methods. Comments are provided in lib/array_practice.rb for each method you will need to write. Run learn to test your solutions.

Conclusion

There are many ways to manipulate arrays of integers. These operations are common enough that some of the methods you've written are actually built into Ruby as class methods. Being able to access and modify array data

Resources

pfwtfp-practice-with-array-integers-lab-dc-web-mod1-repeat's People

Contributors

maxwellbenton avatar

Watchers

 avatar Mohawk Greene avatar Victoria Thevenot avatar Bernard Mordan avatar Otha avatar raza jafri avatar  avatar Joe Cardarelli avatar The Learn Team avatar Sophie DeBenedetto avatar  avatar  avatar Matt avatar Antoin avatar  avatar Alex Griffith avatar  avatar Amanda D'Avria avatar  avatar Ahmed avatar Nicole Kroese  avatar Kaeland Chatman avatar Lisa Jiang avatar Vicki Aubin avatar  avatar  avatar  avatar

Forkers

musiccity365

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.