Coder Social home page Coder Social logo

intro-to-simple-array-manipulations-001's Introduction

Objectives

  1. Become comfortable using the official documentation of the Ruby Language
  2. Gain proficiency performing simple array manipulations
  3. Gain proficiency understanding the result of method calls on arrays

Introduction To Simple Array Manipulations

In a previous lab, you learned how to create arrays and access the elements of an array. Now you are ready to manipulate arrays using different ruby methods.

Make sure to consult the Official Documentation of the Ruby Language when solving this lab.

Instructions

Fork and clone this lab. Run rspec and write the methods in lib/introduction_to_simple_array_manipulation.rb to get the tests passing.

Consult the official documentation of the Ruby Language for the methods you need to use to solve the problems in this lab.

As you read the method descriptions, make sure to pay attention to understanding what the method returns. For instance, when you call .push on an array, it returns the updated array:

artists = ["Hozier", "Ariana Grande", "Usher"]
next_artist = "Beyonce"
artists.push(next_artist)
# => ["Hozier", "Ariana Grande", "Usher", "Beyonce"]

However, .pop works a little differently. Pop removes the last element from an array. Let's take a look:

artists = ["Frida Kahlo", "Pablo Picasso", "Cai Guo-Qiang"]
artists.pop
# => "Cai Guo-Qiang"

artists
# => ["Frida Kahlo", "Pablo Picasso"]

You can see that while pop removes an element from an array, its return value is the last element, in this case "Cai Guo-Qiang".

One of the most common problems you will encounter on your journey to becoming a software developer is not knowing what object a method returns. For example: you might assume that the result of a method call is a string but instead it is an array.

intro-to-simple-array-manipulations-001's People

Contributors

msuzoagu avatar deniznida avatar kthffmn avatar fs-lms-test-bot avatar irmiller22 avatar matthewkrey avatar fislabstest avatar changamanda avatar

Watchers

James Cloos avatar Ruth Mesfun 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.