Help with Hashes review


#1

DATA STRUCTURE HASHES REVIEW NEED HELP

https://www.codecademy.com/en/courses/ruby-beginner-en-F3loB/3/2?curriculum_id=5059f8619189a5000201fbcb

what i get Oops, try again. Did you declare a variable called my_hash?

output is this
flash
1
superman
2
batman
3
"money"

powers = { "flash" => 1,
  "superman" => 2,
  "batman" => 3
}

powers.each do |powers,hero|
    puts powers,hero
end

ability = Hash.new
ability ["flash"] = "speed"
ability ["superman"] = "strenght"
ability ["batman"] = "money"


#2

The instructions below are all you need to do to pass the SCT. :slight_smile:

1. Create a hash called myhash in the editor._

2. Give it at least one key-value pair.

You don't need all of this,

powers = { "flash" => 1,
  "superman" => 2,
  "batman" => 3
}

powers.each do |powers,hero|
    puts powers,hero
end

ability = Hash.new
ability ["flash"] = "speed"
ability ["superman"] = "strenght"
ability ["batman"] = "money"

#3

thanks i wasnt thinking correctly


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.