17/20


#1

Code comes out right but says that it doesn't. Can someone help?

puts "What's your favorite language?"
language = gets.chomp

case language
when "Ruby" then 'Ruby is great for web apps!'
when "Python" then "Python is great for science."
when "JavaScript" then "JavaScript makes websites awesome."
when "HTML" then "HTML is what websites are made of!"
when "CSS" then "CSS makes websites pretty."
else "I don't know that language!"
end


#2

Your code seems to work, what error do you get?


#3

"Ooops, looks like your program doesn't put "Ruby is great for web apps!", when language == 'Ruby"


#4

Try double quotes instead of single quotes maybe?


#5

Its because the lesson is specifically looking for you to PUTS the response out.

when language == "Ruby"
then puts "Ruby is great for web apps!"

The lesson is being really picky.


#6

Yep, probably this, didn't even see there was no puts or print method ^^.


#7

Same problem here but changed == to = and works fine.


#8

You all were really close, but are slightly off when it comes to Ruby case syntax, the proper syntax is:

case language
when "Ruby" puts "Ruby is great for web apps!"
when "Python" puts "Pyhton is great for science"
...
else puts "I don't know that language"
end

Essentially, the ruby interpreter 'knows' that the string after when in each case is the variable to be interpreted against each case, so therefore you do not need to state:
when language == "Ruby" puts ...
etc.

Ultimately your syntax is wrong and that is why you are getting errors.


#9

That wasn't what @rodgeralien used though.


#10

so what you have @rodgeralien is it correct


#11

This was my code

  puts "What's your favorite language?"
   language = gets.chomp

   case language
   when "Ruby" then puts "Ruby is great for web apps!"
   when "Python" then puts "Python is great for science."
   when "JavaScript" then puts "JavaScript makes websites awesome."
   when "HTML" then puts "HTML is what websites are made of!"
   when "CSS" then puts "CSS makes websites pretty."
   else
     puts "I don't know that language!"
   end

#12

I'm stuck on this one also.... Same code as member above error message (Oops, try again.
Make sure to convert your if/elsif/else construction into a case statement!
)

the correct info is on the console log however will not let me pass onto next step...


#13

In Case of Many Options

Instructions
Refactor the if/elsif/else statement in the editor into a tidy case statement.
Hint Example of refactoring, notice what's not in the code
Here's one way of structuring a case statement:
case variable
when value1 then #Do something!
when value2 then #Do something else!
...
when value9 then #Do another thing!
else
# Do the default thing!
end
This code needs to look like the example above ^
puts "What's your favorite language?"
language = gets.chomp

if language == "Ruby"
puts "Ruby is great for web apps!"
elsif language == "Python"
puts "Python is great for science."
elsif language == "JavaScript"
puts "JavaScript makes websites awesome."
elsif language == "HTML"
puts "HTML is what websites are made of!"
elsif language == "CSS"
puts "CSS makes websites pretty."
else
puts "I don't know that language!"
end


#14

Had the same problem as what @rodgeralien listed. But then used the normal case statement.Here's the code:
puts "What's your favorite language?"
language = gets.chomp

case language

when language = "Ruby"
puts "Ruby is great for web apps!"
when language = "Python"
puts "Python is great for science."
when language = "JavaScript"
puts "JavaScript makes websites awesome."
when language = "HTML"
puts "HTML is what websites are made of!"
when language = "CSS"
puts "CSS makes websites pretty."
else
puts "I don't know that language!"
end

This worked perfectly


#15

I just learned you can puts first before the case begins:

puts "What's your favorite language?"
language = gets.chomp

puts case language
when "Ruby" then "Ruby is great for web apps!"
when "Python" then "Python is great for science."
when "JavaScript" then "JavaScript makes websites awesome." 
when "HTML" then "HTML is what websites are made of!"
when "CSS" then "CSS makes websites pretty."
else "I don't know that language!"
end

I like the elegance of this solution :wink:


#16

I was getting the error message "Ooops, looks like your program doesn't put "Ruby is great for web apps!", when language == 'Ruby"

Summary: I changed == to = and it worked.

My successful code was as below:

puts "What's your favorite language?"
language = gets.chomp

case language
when language = "Ruby" then puts "Ruby is great for web apps!"
when language = "Python" then puts "Python is great for science."
when language = "JavaScript" then puts "JavaScript makes websites awesome."
when language = "HTML" then puts "HTML is what websites are made of!"
when language = "CSS" then puts "CSS makes websites pretty."
else
puts "I don't know that language!"
end


#17

fyi
you can just say 'when "Ruby" ' instead of 'when language="Ruby" '