numbers = [1,2,3]
total = 0
numbers.each do |number|
total += number
end
p total
Updated by: Scott Borecki
[![LinkedIn: scott-borecki][linkedin-badge]][LinkedIn] [![Email: [email protected]][gmail-badge]][gmail] [![GitHub: Scott-Borecki][github-follow-badge]][GitHub]
Please reach out if you have any comments or suggestions for updates!
It's important to note that running this reset will drop any existing data you have in the application
- Step 1:
heroku restart
- Step 2:
heroku pg:reset DATABASE
(no need to change theDATABASE
) - Step 3:
heroku run rake db:migrate
- Step 4:
heroku run rake db:seed
(if you have seed)
One liner
require "pry"
class Game #This game is called "guess what number the computer is thinking of"
attr_reader :player_name, :computer_choice, :game_over
def self.start
game = Game.new
game.get_players
game.start_computer
Updated by: Chris Simmons, based on the 5.2 Cheatsheet by Scott Borecki.
Please reach out if you have any comments or suggestions for updates!
- This guide uses Rails version v7.1.2. Run
rails -v
to check your Rails version number. - Code snippets in this cheatsheet starting with
$
: - Run from the terminal, usually within your project directory.
These prompts taken from this lesson. Highly suggest trying these on your own FIRST before comparing to these solutions.
- Get all songs
Getting a basic response:
response = Faraday.get({url})
You want to build a word cloud, an infographic where the size of a word corresponds to how often it appears in the body of text. For example, if we turn the Gettysburg Address into a word cloud, it might look like this.
To do this, you'll need data!
Write code that takes a long string and builds its word cloud data into a hash (or JSON object), where the keys are the words and the values are the number of times the words occurred.