Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
SOPHIE DEBENEDETTO authored and SOPHIE DEBENEDETTO committed Jun 15, 2015
1 parent 9fad5a5 commit c962574
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
---
tags: arrays, iteration, conditionals
languages: ruby
type: todo
---


# Square Array

## Objectives
1. Practice iterating over an array using the `.each` method.
2. Practice operating on each element of an array.

## Instructions

You will build a method, `square_array`, that squares each element of an array of numbers and returns a new array of these squared elements. Please use an iterator and implement your own logic. Don't use any built in array methods other than `.each`––(collect, inject, etc.)

A few question you can ask yourself:

* What is the return value of calling `.each` on an array?
* How can I operate on each element of an array and also collect or store those elements?

## Bonus

Once you have the tests passing, see if you can implement this with a higher level iterator, maybe `collect`.


Make a method that will square all the elements in an array.

## Examples

Expand All @@ -24,19 +35,6 @@ square_array(new_numbers)
# => [81,100,256,625]
```

## Instructions

Complete spec/square_array.rb and build a method that squares all the elements of an array (assuming they are integers).

## Notes

Please use an iterator and implement your own logic. Don't use any built in array methods other than each. (collect, inject, etc.)

## Bonus

See if you can implement this with a higher level iterator, maybe `collect`.

## Resources

* [Ruby Docs](http://www.ruby-doc.org/core-2.1.2/) - [Each Method](http://www.ruby-doc.org/core-2.1.2/Array.html#method-i-each)

* [Ruby Docs](http://www.ruby-doc.org/core-2.1.2/) - [Each Method](http://www.ruby-doc.org/core-2.1.2/Array.html#method-i-each)

0 comments on commit c962574

Please sign in to comment.